• Post Reply Bookmark Topic Watch Topic
  • New Topic

Use of Map, MultiMap etc  RSS feed

 
Samir Swarup
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any one tell me how to store List of String into Objects using Map like Map(Objects, List<String>)
where as objects has multiple values like ID, NAME, COST
and List having strings which in turn are value of ID, NAME and COST like ID --> 1  2  3  4  5  6    ,   NAME ---> Ana  Akash  Smita  Suresh  John  Jenny    ,   Cost---->20  30  40  50  60  70
So need to store above values using Maps.
Please can anyone suggest.
 
Campbell Ritchie
Marshal
Posts: 56581
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start by creating an object which encapsulates those data. What you have looks very poor design and not object‑oriented programming. You can now create a List of those objects.
Why do you want a Map? That sounds as though you had decided how to do it before deciding what you want to do. You do not store objects in a Map, you store pairs of objects. Have a look in the Java™ Tutorials and remind yourself how Maps work.
You can only understand a multimap after you have come to understand an ordinary Map.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!