Static internal class programming exercise
•
Java
Outer class:
Public class outer {int XX = 10; static int YY = 20; / / static inner class static class inner {int ZZ = 30; / / method of static inner class public void innermethod() {system.out.println ("I am the instance method of static inner class"); system.out.println ("XX = =" + YY "); system.out.println (" XX = = "+ zz);} Public static void sinnermethod() {system. Out. Println ("I'm a static method of a static inner class");}}
}
Test demo class:
Public class demo {public static void main (string [] args) {/ / create internal class objects outer. Inner innerobj = new outer. Inner(); innerobj. Innermethod(); outer. Inner. Sinnermethod();}}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码