aspose file tools*
The moose likes Java in General and the fly likes Intersection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Intersection" Watch "Intersection" New topic
Author

Intersection

Nemanja Gajic
Greenhorn

Joined: Oct 19, 2013
Posts: 1
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

Joined: May 26, 2003
Posts: 30762
    
156

Welcome to CodeRanch!

I don't know what that means either. Are they talking about lists by any chance? Is there any more context?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39409
    
  28
Welcome again

The only thing I ever intersect is two Sets; you can read about Sets in the Java Tutorials.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8008
    
  22

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

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Ashwani Singh
Greenhorn

Joined: May 10, 2013
Posts: 29
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.
 
subject: Intersection