2016-06-30
Packagecom.java1995; Public classStaticinnertest {intCount=1; Public Static voidMain (string[] args) {//to create an object of a static inner classStaticinnertest.inner i=NewStaticinnertest.inner (); } /*** Static Inner class * 1. Add the static modifier to the inner class * 2. Static inner classes can declare static member variables; * 3 is not available in non-static inner classes. Non-static member variables of external classes cannot be accessed in static inner classes * 4. Create an object of a static inner class that does not require an object of an external class * * Internal classes Why can I access member variables of external classes? * @authorAdministrator **/ Static classinner{ Public voidprint () {//System.out.println (count); } }}
Resources
[1] Java Easy Start Classic tutorial "full version"
Java section 43rd static inner class