我正在做以下操作。
Set<Set<String>> set1 = new HashSet<Set<String>>();
Set<Set<String>> set2 = new HashSet<Set<String>>();
set1.add(new HashSet<String>(Arrays.asList("s1","s2")));
set1.add(new HashSet<String>(Arrays.asList("s4","s5")));
set2.add(new HashSet<String>(Arrays.asList("s5","s4")));
ArrayList<String> ob = (ArrayList<String>)CollectionUtils.subtract(set1, set2);
ArrayList<Set<String>> ob1 = (ArrayList<Set<String>>)CollectionUtils.subtract(set1, set2);
System.out.println(ob);
System.out.println(ob1);
它给出以下输出。
[[s2, s1]]
[[s2, s1]]
它不应该在第一种情况下给类转换异常吗?
谢谢,
山塔努