I am using maps and I need them to keep the order objects were put into them but they keep sorting themselves at their will. How do I stop that or is there another collection for that? I got around it by using two ArrayLists but I want to do it with one collection.
import java.util.HashMap;
import java.util.Map;
public class Test {
public static void main(String[] args) {
Map<String, String> map = new HashMap<>();
map.put("b", "Item One");
map.put("a", "Item Two");
map.put("c", "Item Three");
System.out.println(map);
}
}