哈希地图!
例子:
Map attribut = new HashMap();
attribut.put(1, "hi");
String value = attribut.get(1);你可以迭代:
for (Integer key : attribut.keySet()) {
value = attribut.get(key);
}编辑:
好的,只是一对!
public class Pair {
private final K element0;
private final V element1;
public static Pair createPair(K key, V value) {
return new Pair(key, value);
}
public Pair(K element0, V element1) {
this.element0 = element0;
this.element1 = element1;
}
public K getElement0() {
return element0;
}
public V getElement1() {
return element1;
}
}用法:
Pair pair = Pair.createPair(1, "test");
pair.getElement0();
pair.getElement1();永恒,只有一对!