wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes a problem of Hashtable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "a problem of Hashtable" Watch "a problem of Hashtable" New topic
Author

a problem of Hashtable

David George
Greenhorn

Joined: Aug 25, 2005
Posts: 11
String[] string = {"m","n"};
Hashtable<Integer,String[]> t = new Hashtable<Integer,String[]>();

public void test()
{
t.put(1,string);
}

public void get()
{
int[] string = -----
}

May i know how to turn the keys in HashTable to int[]???Thank you .
Thomas Paul Bigbee
Ranch Hand

Joined: Jun 28, 2005
Posts: 71
I don't know what this is doing here, or why you would possible want to do what your trying to do, but anyway...

To successfully store and retrieve objects from a hashtable, the objects used as keys must implement the hashCode method and the equals method.

The below code works, (and, I'll never confess to writing it)

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: a problem of Hashtable
 
Similar Threads
Retrieving hashtable values in JSP
hashtable() in java
Hashtable
Hashtable iteration
Intersection of two arrays