Class outer{ int score =; void Inst () { Inner in = new Inner (); In.display (); } Class Inner { void display () { System.out.println ("Score: score =" +score); }}} public class innerclassdemo{public static void Main (String args[]) { Outer Outer = new Outer (); Outer.score = +; Outer.inst (); Use the inner class Outer.Inner Inner = outer.new Inner () outside the class; Inner.display (); }}
The above code is an example of using an inner class. "Javac Innerclassdemo.java" compiled, "Java Innerclassdemo" executed, printed as follows:
Score: score = 100
Score: score = 100
Inner classes use feeds: Inner classes can use the properties of external classes, but external classes cannot use the properties of inner classes. Internal classes can also be used outside the class, using the last part of the main function.
Java internal classes, literacy stickers