A normal method in a class has a hidden parameter, "this", which identifies which instance the method will operate on. But a static method does not have this hidden parameter, so it can only operate on static members

解决方案 »

  1.   

    class X{
      static m0(){}
      m1(){}
    }比方说,你可以用2种方法来使用m0:
     - X.m0();
     - X x=new X();  x.m0();但对于m1来说就不同:
     - X x=new X();  x.m1();
      

  2.   

        static method 也叫類方法,它可以通過類名直接訪問,也可以通過實例變量來訪問.就像樓上朋友所說的.
    static method不能訪問非static變量.
    static method不能被override 但是可以被overload
      

  3.   

    to楼上的:
    static method可以被override为static method,但不可以被override为non-static method原话见:java2认证考试指南(英文原版),第69页。
      

  4.   

    to:karma(无为),,hahaha88(忧郁的眼神,稀嘘的胡子喳)
    你们讲得我有一点明白了,
    可是对于this.还是有点困难,
    static method and non-static method 有没有this有什么区别?
    我写了这样一段程序,在是否使用static时出现错误,
    non-static method cannot be refrenced from a static context
    是不是只有这一点区别呢?class Hello{
      int x;
      static void xxx(){
      int i=9;
       x=10;
      }
    void yyy(){
      int y;
      y=x;
       }
      }