final  固定常量?
 static  静态变量?
static 是在所有类存在吗?
final只存在一个类里面的固定值?  以前我做一个数据连接类?用的就是static?是不是存在所有的类里? 意思就是公开吗?

解决方案 »

  1.   

    public class Test{
      public static int num1=1;
      public final int num2=2;
    }static属性是类属性 它属于一个类而不是某个对象 在类被加载进运行环境时创建 为这个类的所有对象所共享 即无论你创建多少个对象 这个属性都只会有一个
    像上面num1,我们在类的外部可以通过Test.num1来引用 当然也可以(new Test()).num1 但是不推荐这样做 像Eclipse等会直接把这种写法算作错误final属性 在定义时就必须初始化 而且之后他的值是不允许改变的任何对他的赋值都是错误的 但是 如果没有static属性 final属性是对象属性 即创建一个对象就会创建一个final属性
      

  2.   

    static 静态的,可以直接用类调用
    final 最终的,不可继承不可修改的。
      

  3.   

    static静态,可以不用初始化所在类类来调用类中的此属性
      

  4.   

    final申明的不能修改
    static对象属于类一级,而不属于对象级别
    同一个类的对个副本中,static对象只存在一个,所有类副本共享这个static
      

  5.   

    final通常用来定义常量,在声明的同时或者在构造方法中被显式的赋值。
    static定义静态变量,在程序运行前加载到内存中。
      

  6.   

    static 静态的,属于一个类,可以直接被类调用而不用借助对象。
    final  从字面上来看也可以看出,是最终的。即不可继承不可修改。
    对于是不是公开的问题,还得看前面的访问修饰符(public or private)
      

  7.   

    final:
     Variable's value cannot be changed,
     Methods cannot be overridden,
     Classes cannot be subclassed. static:
      Belongs to the class, not to any particular instance of the class;
      For variables, there is only one copy for all instances of the class. if any instance changes the value, the other instances see that changes;
      For methods, it can be called without having created an instance,and cannot be used the "this" keyword.
      

  8.   

    假如建一个工程,static  在这个工程里面存在,  只是值会改变。