您好我是这个网站的新手,需要帮助我正在努力的程序.我遇到的问题是我似乎无法存储字符串和两个整数(作为坐标).我查看了其他代码,但没有看到值的存储方式.下面是我一直在使用的代码.代码似乎没问题,但在尝试存储值时,我不能将乘法整数.谢谢你的时间
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 map = new HashMap();
map.put(new coords(65, 72), "Dan");
}
}