C
charles
Hi
I am using a Hashmap to store objects and their keys. I am using
jdk1.3 (j2se1.3)
I know that when we store objects in a hashmap, the order in which the
objects are stored in the hashmap are not the same as they were added.
What my requirement is that, I need to maintain the order of the
objects in the HashMap in the order in which I had added the objects
to the hashmap.
but what i see is that, the order gets changed.
Is there any way in which I can maintain order of the ojects, as they
were added to the hashmap.
Any help on this would be very helpful..
The code snippet where I am facing this problem is as follows...
public void processLine(String lineString){
String num = lineString.substring(2,22);
num = num.trim();
String suffix = lineString.substring(22,42);
suffix = suffix.trim();
keyObj adminKey =
new KeyObj();
adminKey.setId(num);
adminKey.setFieldType(suffix);
if(num == null || "".equals(num) ||
suffix == null || "".equals(suffix)){
} else {
hmRequestCollection.put(num + " " + suffix,
adminKey);
}
}//End of processLine method
thanks in advance
Charles
I am using a Hashmap to store objects and their keys. I am using
jdk1.3 (j2se1.3)
I know that when we store objects in a hashmap, the order in which the
objects are stored in the hashmap are not the same as they were added.
What my requirement is that, I need to maintain the order of the
objects in the HashMap in the order in which I had added the objects
to the hashmap.
but what i see is that, the order gets changed.
Is there any way in which I can maintain order of the ojects, as they
were added to the hashmap.
Any help on this would be very helpful..
The code snippet where I am facing this problem is as follows...
public void processLine(String lineString){
String num = lineString.substring(2,22);
num = num.trim();
String suffix = lineString.substring(22,42);
suffix = suffix.trim();
keyObj adminKey =
new KeyObj();
adminKey.setId(num);
adminKey.setFieldType(suffix);
if(num == null || "".equals(num) ||
suffix == null || "".equals(suffix)){
} else {
hmRequestCollection.put(num + " " + suffix,
adminKey);
}
}//End of processLine method
thanks in advance
Charles