提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
将LinkedHashSet的所有元素复制到对象数组
/* from n o w j a v a . c o m*/ import java.util.LinkedHashSet; public class Main { public static void main(String[] args) { LinkedHashSet lhashSet = new LinkedHashSet(); //add elements to LinkedHashSet object lhashSet.add(new Integer("1")); lhashSet.add(new Integer("2")); lhashSet.add(new Integer("3")); Object[] objArray = lhashSet.toArray(); //display contents of Object array System.out.println("LinkedHashSet elements are copied into an Array. Now Array Contains..");