static 是静态变量,可以由类直接访问的。而non-static是需要由对象来访问的

解决方案 »

  1.   

    static
    在类没有实例化就可以调用
      

  2.   

    final
    意味着无法改变,其用途是限定某一个元素为常量.
    即不能指向其它的对象:
    例:
    void simeMethod(final myclass c,final int a[])
    {
      c.field=7;
      a[0]=7;
      c=new myclass();//error
      a=new int[13];  //error
    }
      

  3.   

    Static 型类变量是在第一次载入该类是分配内存空间的,而且是分配一次,对应的内存地址是一直不变的,但内存中存放的值可以改变,在添加final 声明,意味者以后该object Reference 对应的内存中值也不能再发生变化了。 简单说就是内存只有一份,且不能在改变其值。你的问题应该说是static下,有无final的同还是不同。
      

  4.   

    static是静态的,它属于整个类,直接用类名可以调用
    如果没有标明为static则属于对象,必须把类实例化,产生的对象去调用
      

  5.   

    // The effect of final on fields.class Value {
      int i = 1;
    }public class FinalData {
      // Can be compile-time constants
      final int i1 = 9;
      static final int VAL_TWO = 99;
      // Typical public constant:
      public static final int VAL_THREE = 39;
      // Cannot be compile-time constants:
      final int i4 = (int)(Math.random()*20);
      static final int i5 = (int)(Math.random()*20);
      
      Value v1 = new Value();
      final Value v2 = new Value();
      static final Value v3 = new Value();
      // Arrays:
      final int[] a = { 1, 2, 3, 4, 5, 6 };  public void print(String id) {
        System.out.println(
          id + ": " + "i4 = " + i4 + 
          ", i5 = " + i5);
      }
      public static void main(String[] args) {
        FinalData fd1 = new FinalData();
        //! fd1.i1++; // Error: can't change value
        fd1.v2.i++; // Object isn't constant!
        fd1.v1 = new Value(); // OK -- not final
        for(int i = 0; i < fd1.a.length; i++)
          fd1.a[i]++; // Object isn't constant!
        //! fd1.v2 = new Value(); // Error: Can't 
        //! fd1.v3 = new Value(); // change reference
        //! fd1.a = new int[3];    fd1.print("fd1");
        System.out.println("Creating new FinalData");
        FinalData fd2 = new FinalData();
        fd1.print("fd1");
        fd2.print("fd2");
      }
    } ///:~
      

  6.   

    class St{
    int i=0;
    void add(){
      System.out.println(i++);
    }
    public static void main(String args[]){
      for(int i=0;i<100;i++){
    St s=new St();
    s.add();
    }
    }//end of main

    }//打印出0
    class St{
            static int i=0;
    void add(){
      System.out.println(i++);
    }
    public static void main(String args[]){
      for(int i=0;i<100;i++){
    St s=new St();
    s.add();
    }
    }//end of main

    }//打印0 to 99
      

  7.   

    class St{
    static final int i=0;
    void add(){
     
      System.out.println(i++); //!错误
    }
    public static void main(String args[]){
      for(int i=0;i<100;i++){
    St s=new St();
    s.add();
    }
    }//end of main

    }
      

  8.   

    下面的是编译期不能确定其值。
    final int i1 = (int)(Math.random() * 20);//有对象才存在,没个对象创建后保持常量,再创建新对象,就是另外一个值了,在某个特定对象内部有效
    static final int i2 = (int)(Math.random() * 20);//全局有效果,不以来对象,整个类加载器上都是常量
    这个是在编译期可以确定其值:
    final int i3 = 9;
    static final int VAL_TWO = 99;