File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Map key or key in object? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Map key or key in object?" Watch "Map key or key in object?" New topic
Author

Map key or key in object?

nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
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

Joined: Jun 28, 2008
Posts: 580
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:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Map key or key in object?
 
Similar Threads
Struts with ValueObject in HashMap
java desing issue
jaxb hashmap?
generic casting with object.getClass() ?
List box initialization through managed bean