This is strange: A is a collection, and B is a collection of sets:
Set <String> A=new HashSet<String>(); Set <Set<String>> B=new HashSet<Set<String>>();
I added things to them, and the conclusion
System.out.println(A)
is an:
[evacuated, leave, prepc_behind]
and conclusion
System.out.println(B)
is an:
[[leave, to, aux], [auxpass, were, forced], [leave, evacuated, prepc_behind]]
as you can see, the third element of the set B is equal to the set A. Thus, hypothetically
if(B.contains(A)){...}
should return true, but apparently it is not. What is the problem?
More details:
Pattern pattern = Pattern.compile("(.*?)\\((.*?)\\-\\d+,(.*?)\\-\\d+\\).*"); for (int i = 0; i < list.size(); i++) { Set <String> tp = new HashSet<String>(); Matcher m = pattern.matcher(list.get(i).toString()); if (m.find()) { tp.add(m.group(1).toLowerCase()); tp.add(m.group(2).toLowerCase()); tp.add(m.group(3).toLowerCase()); } B.add(tp); } Set <String> A=new HashSet<String>(); A.add("leave"); A.add("evacuated"); A.add("prepc_behind"); System.out.println(A); if(B.contains(A)){ System.out.println("B contains A"); }
source share