I have a class like this:
public class StringCheckLHMapSorted<K, V>
extends
ObjectLHMapSorted<K, V> {
I have a LinkedHashMap inside declared as follows:
private final Map<Integer, StringCheck> scoLHMap =
(Map<Integer, StringCheck>) new LinkedHashMap<K, V>();
The class StringCheck has this attributes with its respective setters/getters and nothing else inside:
private boolean check;
private String string;
I created a method inside the class described at the top of this question like this:
public LinkedHashMap<Boolean, String> getSCLHAllStringAndCheckInside() {
LinkedHashMap<Boolean, String> allStrCh = new LinkedHashMap<Boolean, String>();
for (Map.Entry<Integer, StringCheck> e : scoLHMap.entrySet()) {
allStrCh.put(e.getValue().isCheck(), e.getValue().getString());
}
return allStrCh;
}
The object returned allStrCh gives me only one entry; the last one inserted to be more specific. I've replaced allStrCh with an ArrayList to get only keys/values and it gives me the complete list of each one of them; keys/values.
Why is this happening? Am I missing something?