import java.util.HashSet;
import java.util.Iterator;
public class Test {
public static void main(String[] args) {
HashSet hashSet = new HashSet();
hashSet.add(new Integer(1)); // 向集合中添加一个整数
hashSet.add("a"); // 向集合中添加一个字符串
int x[] = { 1, 2, 3, 4, 5 };
hashSet.add(x); // 向集合中添加一个数组
Iterator it = hashSet.iterator();
while (it.hasNext()) {
Object obj = it.next();
if (obj.getClass().isArray()) {//if(obj instanceof int[]){
int[] array = (int[]) obj;
for (int i = 0; i < array.length; i++) {
System.out.println("========" + array[i]);
}
}
}
}
}
import java.util.Iterator;
public class Test {
public static void main(String[] args) {
HashSet hashSet = new HashSet();
hashSet.add(new Integer(1)); // 向集合中添加一个整数
hashSet.add("a"); // 向集合中添加一个字符串
int x[] = { 1, 2, 3, 4, 5 };
hashSet.add(x); // 向集合中添加一个数组
Iterator it = hashSet.iterator();
while (it.hasNext()) {
Object obj = it.next();
if (obj.getClass().isArray()) {//if(obj instanceof int[]){
int[] array = (int[]) obj;
for (int i = 0; i < array.length; i++) {
System.out.println("========" + array[i]);
}
}
}
}
}