求教一下代码错误提示地解决方法:
错误提示:
  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)};
  }
}

解决方案 »

  1.   

    不能在静态函数里(main())用内部类,还有lesson42声明为public
      

  2.   


    public class Lession42 {
    class   Point{ 
          int   x,y;    Point(int   x,int   y){        this.x=x; 
          this.y=y;        } 
      } 
      public   static   void   main(String[]   args)   { 
          Lession42 lession=new Lession42();
          Lession42.Point p=lession.new Point(1,1);
      } 
    }
      

  3.   

    静态变量是指用static修饰的,你不可以用非静态变量去访问静态的
      

  4.   

    point  是内部类  ,非静态内部类 需要 外部类 支撑,所以 必须先实力化外部类 , 再实力化非静态内部类,语法规则如下:
    Lession42 lession=new Lession42();
    Lession42.Point p=lession.new Point(1,1);
    也可以:
    Lession42.Point p= new Lession42().new Point(1,1);
      

  5.   

    三楼的正解
    要有一个PUBLIC类
      

  6.   

    class Lession42 
    {
    static 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);
    }
    }
    不想加PUBLIC 这样也可以!