1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
import java.util.*;
public class ToTest {
public ToTest() {
}
public void go() {
TreeSet <String> ts = new TreeSet <String> ();
ts.add("key1");
ts.add("key4");
ts.add("key2");
ts.add("key8");
ts.add("key5");
for (String entree : ts) {
System.out.println(entree);
}
TreeMap <String, String> MaMap = new TreeMap <String, String> ();
MaMap.put("key1","coucou1");
MaMap.put("key4","coucou4");
MaMap.put("key2","coucou2");
MaMap.put("key8","coucou8");
MaMap.put("key5","coucou5");
for (Map.Entry entree : MaMap) {
System.out.println("Clé : "+entree.getKey()+" Valeur : "+entree.getValue());
}
}
} |
Partager