Convert set to Array - Java Collection Framework

Java examples for Collection Framework:Array Convert

Description

Convert set to Array

Demo Code


//package com.java2s;

import java.util.Set;

public class Main {
    public static <T> T[] set2Array(Set<T> oSet) {
        Object[] oArray = oSet.toArray(new Object[] {});
        T[] ts = (T[]) oArray;//from  ww w. j a  v  a2  s  .  c om
        return ts;
    }
}

Related Tutorials