在静态方法中访问类的实例成员

 

 

源代码:blog

package team4;
/**  *  * @author 郝子嘉  *  */ public class Test {  int A=5;  static int B=7;  public static void show(){   System.out.println("实例变量A为"+new Test().A);   System.out.println("静态变量B为"+B);  }  public static void main(String[] args){   Test.show();   Test t=new Test();   System.out.println("A为"+t.A);  } }
相关文章
相关标签/搜索