Ahojte, potreboval bych strukturu podobnou objektu HashMap, ale nesmi jakkoliv reorganizovat polozky. Muj kod:
public static HashMap<Integer, String> lastTextbook() {
HashMap<Integer, String> map = new HashMap<Integer, String>();
map.put(-1, "New Headway");
map.put(1, "Elementary");
map.put(2, "Pre-intermediate");
map.put(-2, "New English File");
map.put(5, "Elementary");
map.put(6, "Pre-intermediate");
map.put(-3, "New Matrix");
map.put(9, "Pre-intermediate");
map.put(10, "Intermediate");
return map;
}
a tento kod to zpracovavaIterator it = lastTextbook().keySet().iterator();
while (it.hasNext()) {
Integer value = (Integer)it.next();
String text = (String)options.get(value);
System.out.println(text);
}
a tohle mi vypise nasledujici vystupElementary
Pre-intermediate
Elementary
Pre-intermediate
Pre-intermediate
Intermediate
New Matrix
New English File
New Headway
jenze ja potrebuji, aby mi to vypsalo presne v poradi, v jakem jsem to tam vlozil. Jakou strukturu bych mel pouzit? Dekuji :-)