1.在jvm退出时自动释放
2.在类的装载时分配
3.不管new 多少个,内存中只有一个静态属性

解决方案 »

  1.   

    static变量在不退出JVM时永久常驻内存.
    无论你new TestBean几次...只有一个static变量在内存中!
      

  2.   

    1 对于核心java api类应该是在jvm退出时,非核心类应该是在此类被卸载时吧。
    2 应该是类被连接时的准备阶段吧。
      

  3.   

    例如:
    TestBean{
      public static String url="XXX";
      TestBean(){
      }
      TestBean(String s){
        url =s;
      }
    }
    第一次:new TestBean()...结果:TestBean.url="XXX"
    第二次:new TestBean("TTT")....结果:TestBean.url="TTT"
    第三次:new TestBean()...结果:TestBean.url=????第3次的结果是什么呢???
      

  4.   

    TestBean.url为最近一次改变的值"TTT"对于静态属性为了程序可读性强和不易混肴应直接用类名作前缀来引用操作如上用TestBean.url="TTT"
      

  5.   

    static变量在内存中仅有一份,无论你产生多少个对象,他们都共享一个STATIC变量,而不是该变量的拷贝,在JVM没有被终止前,它常驻内存的静态存储空间(static storage),静态存储空间存放着程序执行期间一直存在的数据,
      

  6.   

    If a field is declared static, there exists exactly one incarnation of the field, no matter how many instances (possibly zero) of the class may eventually be created. A static field, sometimes called a class variable, is incarnated when the class is initialized (§12.4).A field that is not declared static (sometimes called a non-static field) is called an instance variable. Whenever a new instance of a class is created, a new variable associated with that instance is created for every instance variable declared in that class or any of its superclasses.