static member和static function吗?
这个问题就大了。

解决方案 »

  1.   

    简言之,static成员就是由此对象的所有实例共享的成员;
    static方法是可以不通过对象实例直接调用的方法,其中不可以使用非静态的类成员;
    还有static内部类呢,Thinking in JAVA里有很好的用法。
      

  2.   

    //比如:
    class Test
    {
         static int method1(int x,int y)
         {
              return (x+y)*x*y;
         }
         public int method2(int x,int y)
         {
              return (x-y)*x*y;
         }
    }public class TestJava
    {
        public static void main(String [] args)
        {
             int m;
             int n;
             m=Test.method1(4,6);
             Test newTest=new Test();
             n=newTest.method2(5,3);   //NO n=Test.method2(5,3)
             System.out.println("m = " + m);    // m=240
             System.out.println("n = " + n);    // n=30
        }
    }