• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Map key or key in object?

 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is better:

To use something like this:




or is it better, to replace the String-Key of the Map as a property of MyObject, doing this, I can replace my Map to a List:



What is better? When should I prefer the first one?
 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, I guess I have to use the Map, as I cannot access a Object within the list directly.

In a map I can say:



and it returns the corresponding object. If I put the key as a property in MyObject, then I cannot retrieve this object directyl:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic