在靜態方法中訪問類的實例成員

 

 

源代碼: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);  } }
相關文章
相關標籤/搜索