aspose file tools*
The moose likes Beginning Java and the fly likes For good programming, In the Hasp Map programming, what value given to Key. As I know I can put any Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "For good programming, In the Hasp Map programming, what value given to Key. As I know I can put any " Watch "For good programming, In the Hasp Map programming, what value given to Key. As I know I can put any " New topic
Author

For good programming, In the Hasp Map programming, what value given to Key. As I know I can put any

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
For good programming, In the Hasp Map programming, what value given to Key. As I know I can put any string
Sandeep Kumar Jakkaraju
Ranch Hand

Joined: Feb 25, 2009
Posts: 75
please put your car key in it .... so that you can find it easily .....
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

jacob deiter wrote:In the Hasp Map programming, what value given to Key. As I know I can put any string


Not only Strings, Any java object is acceptable. And null also possible. Check the API


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

But be careful that you don't change the results of hashCode by changing some field, or your key cannot be found again with get().

Once you add an object to a hash map its hashCode should never change. If it needs to, remove the object from the map first, then change the object, then add it again.

For example:

The fix is really easy:

This is actually why String and the primitive wrapper objects are such good candidates for maps - they are immutable (i.e. they never change).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: For good programming, In the Hasp Map programming, what value given to Key. As I know I can put any
 
Similar Threads
put values in the TreeMap
how to access hash-map in JSP using struts tags
Populating Select Options in Struts Application
Question regarding Map interface
I want to check previous (value) of HashMap before adding the current key?