aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Regarding java.util.List Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Regarding java.util.List" Watch "Regarding java.util.List" New topic
Author

Regarding java.util.List

Krish Pinnamaneni
Greenhorn

Joined: Mar 16, 2005
Posts: 22
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

Joined: Jul 19, 2004
Posts: 298

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

Joined: Mar 15, 2005
Posts: 88
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

Joined: Mar 01, 2005
Posts: 485
hi sri
i didn't the what the INTEGER OBJECT meant here.
please explain
Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
hi sri
i didn't the what the INTEGER OBJECT meant here.
please explain
sri rallapalli
Ranch Hand

Joined: Mar 15, 2005
Posts: 88
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.
 
 
subject: Regarding java.util.List
 
Similar Threads
HFS question 15 page # 423
EL mock exam question - what's YOUR answer?
collection doubt again
Doubt in EL
EL Question from HFSJ