Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Intersection  RSS feed

 
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
Sheriff
Posts: 36406
454
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: 53750
127
  • 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
Posts: 10573
65
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!