在stackoverflow的某个地方,我找到了关于2个值的解决方案。
public class Pair<A, B> {
A first = null;
B second = null;
Pair(A first, B second) {
this.first = first;
this.second = second;
}
public A getFirst() {
return first;
}
public void setFirst(A first) {
this.first = first;
}
public B getSecond() {
return second;
}
public void setSecond(B second) {
this.second = second;
}
}
public static HashMap<Player, Pair<HorseModifier, LivingEntity>> P_and_h =
new HashMap<Player,Pair<HorseModifier, LivingEntity>>();;
问题是:
P_and_h.put(p, new Pair(hm, hm.getHorse()));
if(P_and_h.containsValue(HorseModifier))` - dont working ( this is first object)