Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Intersection and union set

  Asked By: Pedro    Date: May 31    Category: Java    Views: 1042
  

I am newbie in java...I want to do intersection and union set
program...I have a set data in list like [ [abc] [ac] [abc] [b] [a] ]

For the first three set....it can do intersection and get new set as
[ac] but when find [b] it will return [ ]...I want it return [ac]
[b]..and then find [a] it will return [c][b]...anyone could help me...
Below is my program :

public static void intersect(List listSet2) {
Set inter = new HashSet((Set)listSet2.get(0));
Set union = new HashSet();

for (int i=1; i < listSet2.size(); i++){
inter.retainAll((Set)listSet2.get(i));
System.out.println("Inter " + inter);
}
}

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Intersection and union set Or get search suggestion and latest updates.




Tagged: