Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding java.util.List

 
Krish Pinnamaneni
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
We know that java.util.Map is not a collection since it is not implementing Collections interface.
is there any way to convert java.util.List to java.util.Map. waiting for guidance
In Advance,
Thanks,
Krish
 
Animesh Shrivastava
Ranch Hand
Posts: 298
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,
We know that java.util.Map is not a collection since it is not implementing Collections interface.
is there any way to convert java.util.List to java.util.Map. waiting for guidance


Map is a collection of key value pairs. But List is a collection of elements. To convert it to a map u have to attach a unique key(or value) to each element in the list, so that it acts as map. In that case just iterate thru and for each element add a key to it( or value)

I hope thats clear
 
sri rallapalli
Ranch Hand
Posts: 88
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
map stores data in key/value pairs. But list is having only objects.
so one thing what u can do is, as a key element u can store Integer object, and as a value u can store list objects. But otherwise it is not possible.
any comments!!
sri.
 
Parameswaran Thangavel
Ranch Hand
Posts: 485
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi sri
i didn't the what the INTEGER OBJECT meant here.
please explain
 
Parameswaran Thangavel
Ranch Hand
Posts: 485
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi sri
i didn't the what the INTEGER OBJECT meant here.
please explain
 
sri rallapalli
Ranch Hand
Posts: 88
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Parameswaran,
U need to store Key/ value pairs into Map right.
Any way we are going to store List objects as Value, we need to store some object into the map as a Key. So it will be easy if we canb store Integers as Keys. We cant store integer primitive data type here, so i said integer objects.
i think u got my point.
sri.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic