<span style= "FONT-SIZE:18PX;" >package Nested_inner_class;public class StaticNestedTest1 {public static void main (string[] args) {//Do not require an instance of the You can create an inner class object directly outer1.nested1 nested1 = new outer1.nested1 (); System.out.println (Nested1.getvalue ());}} class Outer1{private static int value = 9;//static nested class (NESTED1) can access all (including private) members of the Outer class (Outer)//can understand the nested class as a function of the outer class ( Why can I access members of an external class) static class Nested1{int GetValue () {return value;}}} </span>
Nested classes (nested Class) are classes that are declared inside another class or interface. Nested classes are divided into two types: static inner classes (the static inner Class) and non-static nested classes (Non-static nested Class). Non-static nested classes are also known as Inner classes (inner class)
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java Nested classes and inner class examples < a >