• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Regarding java.util.List

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic