我正在创建一个新的 Map 并将字符串推入其中(没什么大不了的)- 但我注意到随着 Map 的增长,字符串正在被重新排序。是否有可能停止这种重新排序,使 Map 中的项目保留它们被插入时的顺序?
Map<String,String> x = new HashMap<String, String>();
x.put("a","b");
x.put("a","c");
x.put("a","d");
x.put("1","2");
x.put("1","3");
x.put("1","4");
//this shows them out of order sadly...
for (Map.Entry<String, String> entry : x.entrySet()) {
System.out.println("IN THIS ORDER ... " + entry.getValue());
}