谁能给我讲讲java中静态方法和静态变量的含义和使用方法,谢了~~~

解决方案 »

  1.   

    java中静态方法和静态变量你理解为类方法和类变量就可以了,也就是说只要有类对象存在,你就可以调用其类方法,而不用生命一个对象才能调用。
      

  2.   

    静态变量和方法基本可以理解为类变量和类方法  另外就是静态的东西创建后只在JVM里面保存了一个唯一的副本...
      

  3.   

    静态方法就是不用new对象,直接用 Object.method()就可以用!
      

  4.   

    public class Test1 { 
    public static final String MY_STR = "test"; 
    public static String test(){ 
    String str = MY_STR; //非静态变量在静态方法中不能访问
    return str; 

    }public class Test2 { 
    public String test(){ 
    String str = "test"; 
    return str; 

    } public class Test { 
    public static void main(String args[]){ 
    Test2 test2 = new Test2(); 
    String str2 = test2.test(); String str1 = Test1.test();
    String str3 = Test1.MY_STR ;


    }