EDIT: All code and database script creation can be found from http://gitorious.org/scheator . The script database is located in Schema /.
I have the following Java code:
LinkedHashMap link defined in an abstract class as
LinkedHashMap<Object, Data> list;
The descendant class that initializes this list as follows:
list = new LinkedHashMap<Integer, Data>();
I add the following elements:
String id = rs.getString(FIELDS[0]); String name = rs.getString(FIELDS[1]); Data team = new Data(Integer.parseInt(id.trim()), name); list.put(id, team);
Now when I do this:
System.err.println("delete() count: " + list.size()); System.err.println("delete() key value " + key); Data obj; obj = (Data)list.remove(key); deletedList.put(key, obj); System.err.println("delete() count: " + list.size());
Nothing is removed from the list, i.e. the first and last prints print the same size (). The key is also correct (I checked that there is an element of this identifier).
However, and this is my question, if I add the following values:
Integer id = rs.getInt(FIELDS[0]); String name = rs.getString(FIELDS[1]); Data team = new Data(id, name); list.put(id, team);
The code works! Should parseInt () create a similar key for getInt ()? Why does the second version work, but the first does not work? I spent a good hour debugging until I found a reason, and I still can't figure out the reason.