sdfsdf dfgfg fggg fdggg sddsf
static可直接存取 public static void main(String[] args) { exstatic obj1 = new exstatic(); exstatic obj2 = new exstatic(); // 存取static欄位 exstatic.static_a = 100; //直接存取 static 的變數 System.out.println("類別欄位="+exstatic.static_a); //直接存取類別方法 exstatic.stMethod(); //存取實體欄位 obj1.instance_a=10; obj2.instance_a=20; System.out.println("實體欄位="+obj1.instance_a); System.out.println("實體欄位="+obj2.instance_a); }} class exstatic{ static int static_a=100; int instance_a; static void stMethod() { System.out.println("static方法"); } } .msgcontent .wsharing ul li { text-indent: 0; } 分享 Facebook Plurk YAHOO!
好站連結:http://ybcfcai.pixnet.net/blog
留言列表