dictionary - Java map value returns null -


i have kind of strange problem. have simple map called vectors store strategypairs keys , vectors values. when print it, result:

{net.softwarepage.facharbeit.normalgame.logic.strategypair@131e56d7=(1.0;2.0), net.softwarepage.facharbeit.normalgame.logic.strategypair@1e1bc985=(2.0;2.0), net.softwarepage.facharbeit.normalgame.logic.strategypair@d5415975=(0.0;2.0), net.softwarepage.facharbeit.normalgame.logic.strategypair@5bf8c6e7=(2.0;1.0)} 

as can see strategypair@131e56d7 mapped vector (1,2). create new strategypair. when print strategypair@131e56d7 (the same 1 before). however, if call vectors.get(strategypair) returns null. somehow strange key same (at least prints exact same thing out when print it...)

the problem arises when rename strategy, e.g. change property name in class "strategy". map contains strategypairs (a wrapper class 2 strategies) messed explained before...

edit: when print hashmap still same result above, following code:

for(strategypair pair : vectors.keyset()) {             system.out.println(vectors.get(pair)); } 

returns: null (2.0;2.0) null (2.0;1.0)

as @rajendra gujja mentioned in comment, "hashcode of keys should not change after keep them in map". true; once changed hashcodes use uuid instead of name property changes, problem solved. of answers!


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -