这是我第一次使用积分,我在最初设置Point2D对象的位置时似乎遇到了问题。这是我的代码片段:
public class Circle {
private Ellipse2D circle;
private int radius,speed=4,direction;
private Color color;
private Point2D.Double loc=null;
private final int MAXSIZE = 15;
public Circle() {
int tempRadius,x,y;
//setting default color
...
//initializing radius
...
//initializing location
x=temp.nextInt(1024); y=temp.nextInt(1024);
loc.setLocation((double)x, (double)y);
尝试执行loc.setLocation()时,我得到nullpointer异常。我一直在努力弄清楚我是否错误地初始化了point2s,如果是这样的话。有人能帮助我吗?
答案 0 :(得分:2)