class beyond{publicstaticvoidmain(String []args){//外部類名.內部類名 對象名 = 外部類名.內部類對象(new 內部類名)/*Outer.Inner yy = Outer.new Inner(); 類里面有個非靜態方法,需要new創建Inner對象;正常的形式是這樣的,但是我們習慣將new放在前面即以下形式*/Outer.Inner yy = new Outer.Inner();yy.method();Outer.Inner2.print();//一路 類名.調用 即可;}
}class Outer{static class Inner{publicvoidmethod(){System.out.println("method");}}static class Inner2{publicstaticvoidprint(){System.out.println("print");}}
}
例題:
要求:用已知的變量,在控制臺輸出30,20,10.
class Test1_InnerClass{publicstaticvoidmain(String [] args){Outer.Inner yy = new Outer().new Inner();yy.show();}
}
//內部類之所以能獲取到外部類的成員,是因為它能獲取到外部類的引用外部類名.this;
class Outer{publicint num = 10;class Inner{publicint num = 20;publicvoidshow(){int num = 30;System.out.println(num);//局部變量num=30;System.out.println(this.num);//成員變量num=20;System.out.println(Outer.this.num);//外部類的成員num=10;}}
}
目錄各類運算時狀態標志的響應變化標志符在各種ADD運算下的響應情況標志符在各種SUB運算下的響應情況借助標志符實現多位數之間運算ADC(add with carry)帶進位加法指令SBB(subtract with borrow)帶借位減法指令各類運算時狀態標志的響應變化
標志符具體含義CF(Carr…
集合類unmodifiableSortedSet()方法 (Collections Class unmodifiableSortedSet() method) unmodifiableSortedSet() method is available in java.util package. unmodifiableSortedSet()方法在java.util包中可用。 unmodifiableSortedSet() method is used to get a non-modi…
在上篇《NHibernate初學體檢記》中,我參照NHibernate官方快速指南寫了兩個示例項目,在示例2的源碼中充斥了如下類似的代碼:<?XML:NAMESPACE PREFIX O />Configuration cfg new Configuration(); cfg.AddAssembly("…
java 方法 示例集合類SynchronizedSortedSet()方法 (Collections Class synchronizedSortedSet() method) synchronizedSortedSet() method is available in java.util package. java.util軟件包中提供了sharedSortedSet ()方法 。 synchronizedSortedSet() method is used to …