求教一下代码错误提示地解决方法:
错误提示:
non-static variable this cannot be referenced from a static context at line 14 (14:14)
class lesson42 {
class point{
int x,y; point(int x,int y){ this.x=x;
this.y=y; }
}
public static void main(String[] args) {
point p = new point(1,1);
point[] pt1 ;//=new point[]{ new point(1,1),new point(2,2),new point(3,3)};
}
}
错误提示:
non-static variable this cannot be referenced from a static context at line 14 (14:14)
class lesson42 {
class point{
int x,y; point(int x,int y){ this.x=x;
this.y=y; }
}
public static void main(String[] args) {
point p = new point(1,1);
point[] pt1 ;//=new point[]{ new point(1,1),new point(2,2),new point(3,3)};
}
}
这里应该这样写:lesson42.point p = new lesson42().new point(1, 1);
这里应该这样写:lesson42.point p = new lesson42().new point(1, 1);
class lesson42 {
class point {
int x, y; point(int x, int y) { this.x = x;
this.y = y; }
} public static void main(String[] args) {
lesson42 l = new lesson42();
point p = l.new point(1, 1);
point[] pt1;// =new point[]{ new point(1,1),new point(2,2),new
// point(3,3)};
}
}