Write a static inner class
1 Public classStaticlei2 {3 Public intAge = 20;4 Public Static intwhit = 30;5 6 Public voidTest ()7 {8SYSTEM.OUT.PRINTLN ("Test");9 }Ten Public Static voidtest1 () One { ASystem.out.println ("Test1"); - } - Public Static classLei//Create an inner class the { - Public intAge = 40; - Public Static intwhit = 50; - + Public voidtest3 () - { + intb=Staticlei.whit; ASystem.out.println ("Test3"); at } - Public Static voidtest2 () - { - -System.out.println ("Test2"); - } in } - Public Static voidMain (string[] args) to { +Staticlei.lei lei =NewStaticlei.lei ();//Create an inner class object -Staticlei.lei.test2 ();//calling a static inner class method theLei.test3 ();//common methods for calling internal classes *System.out.println (Lei.age);//Calling member variables $System.out.println (Lei.whit);//Calling member variablesPanax NotoginsengStaticlei.test1 ();//calling the external static method - the } +}
Java static inner class static