• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Intersection

 
Nemanja Gajic
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know how can I find intersection of 2 objects in Java.
And what can that mean?
Thanks
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34208
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

I don't know what that means either. Are they talking about lists by any chance? Is there any more context?
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again

The only thing I ever intersect is two Sets; you can read about Sets in the Java Tutorials.
 
Winston Gutkowski
Bartender
Pie
Posts: 10257
59
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:The only thing I ever intersect is two Sets...

Or lines. Could they be lines in a graph, or a display?

Inquiring minds want to know.

Winston
 
Ashwani Singh
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nemanja Gajic wrote:Does anyone know how can I find intersection of 2 objects in Java.
And what can that mean?
Thanks


Two objects might be two sets(it can be an array,arraylist,set,hashmap etc).You need to obtain sets between which you want to find out intersection and can obtain the common values of those sets.

like:

List<String> listset=new ArrayList<String>();
listset.add("abc");
listset.add("dfvgd");
listset.add("sdf");

String arr[]=new String[3];
arr[0]="abc";
arr[1]="bnm";
arr[2]="poi";

now you can take these two objects: listset and arr and can find intersection.

Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic