こんにちは私はこのサイトに不慣れで、プログラムの助けが必要です。私が抱えている問題は、文字列と2つの整数(座標として)を格納できないように見えることです。私は他のコードを見ましたが、値がどのように保存されているのかわかりません。以下は、iveが使用しているコードです。コードは問題ないようですが、値を格納しようとすると、乗算整数を入力できません。御時間ありがとうございます
import java.util.HashMap;
public class map {
class Coords {
int x;
int y;
public boolean equals(Object o) {
Coords c = (Coords) o;
return c.x == x && c.y == y;
}
public Coords(int x, int y) {
super();
this.x = x;
this.y = y;
}
public int hashCode() {
return new Integer(x + "0" + y);
}
}
public static void main(String args[]) {
HashMap<Coords, Character> map = new HashMap<Coords, Character>();
map.put(new coords(65, 72), "Dan");
}
}