How can i to return the difference between two collections in java? i have to collections that contains points and complexs . point z=new point (1,2); complex x=new complex(4,5); point f=new complex(5,2); point h=new point(7,8); point k=new point (9,2); Set a=new Set (5); a.add(z); a.add(x); a.add(f); a.add(h); a.add(k); Set b=new Set(3); b.add(z); b.add(x); b.add(f); a.dif(b); the answer should to be: point , point

use removeAll to remove all the elements in b from(a copy of) a... what ever is left is the answer

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.