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 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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
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: 3858

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: 19781
    
  20

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