數(shù)組中可以包含什么類型的元素?
String[] strs = {"a","a","b","b","c","c","d"}; Collection c1 = new HashSet(); Collection c2 = new HashSet(); for(String str : strs){ if(!c1.add(str)){ c2.add(str); } } c1.removeAll(c2); System.out.println(c1);
數(shù)組中可以包含什么類型的元素?
String[] strs = {"a","a","b","b","c","c","d"}; Collection c1 = new HashSet(); Collection c2 = new HashSet(); for(String str : strs){ if(!c1.add(str)){ c2.add(str); } } c1.removeAll(c2); System.out.println(c1);