This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

arraylist

 
vijayapriya thirumurugan
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


hello sir,

i used object[][] el=new object[10][10]; to store arraylist in the form of matrix. and i got the output

[1, 3] null null null null
null [1, 2] null null null
null null [2] null null
null null null [] null
null null null null [1, 3]

my problem is :

[1,3] is in the position el[1][1] , [1,2] is in the position el[2][2]. where [1,3] is arraylist [1,2] , [2] ,[], [1,3] are also arraylist.
i want to get the common element between [1,3] and [1,2] i.e. the answer will be [1]. like this i want to get common elements which is of arraylist format.
can you help me. i'm waiting..
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't understand the question, I am afraid.
 
vijayapriya thirumurugan
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


i got the about output.. i want to get common element between two arraylist
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't return a "common element" because there might not be one common element. You can however search for a set of common elements.

I would convert the two Lists to Sets, then use the "bulk" methods of the Set interface. Look here and here.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic