A set of sets with duplicate names?
I am planning the next homework assignment which is an anagram search. I am using java and want to know if you have a Set where each Set has the same name currentSet (the names of each set are not unique or dynamically generated? If this is too vague, I can post my code to express this in context . Respectfully.
+3
source to share
1 answer
As @Hunter mentioned, you can have Set of Sets. The code will be something like this:
import java.util.*;
public class TestingSets {
public static void main(String[] args) {
Set<Set<String>> mainSet = new HashSet<Set<String>>();
Set<String> s;
for (int i=0; i<10; i++){
s = new HashSet<String>();
s.add("Hi "+i);
mainSet.add(s);
}
}
}
+2
source to share