• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Java help!

RichieZ

Diamond Member
I want to have a hashmap that has a key that is a string and a value that is a double. But it won't let me put it in.

heres a snippet of code:
TFIDF.putKey(cKey, score);

and the error i get is:

The method putKey(Object, double) is undefined for the type HashMap

arg, any help is appreciated
 
Originally posted by: SynthDude2001
You'll have to wrap the double value in a new instance of the Double wrapper class.

thanks, but no cigar. I wrapped ints in the Integer wrapper and that works, but it doesn't work for doubles:

The method putKey(Object, Double) is undefined for the type HashMap

Any more thoughts? I'd really like to avoid storing it as a string and having to use Dobule.parseDouble to retrieve it later.
 
the method is put not putKey

put(Object key, Object value)
Associates the specified value with the specified key in this map.
 
Originally posted by: Spencer278
the method is put not putKey

put(Object key, Object value)
Associates the specified value with the specified key in this map.

Yeah, I was looking through the API specifications and was about to say the same thing....

To the OP - don't worry, we all make dumb mistakes when we're programming in the middle of the night. 😛
 
Back
Top