Detailed examples of Java internal classes
•
Java
Detailed examples of Java internal classes
You can put the definition of one class inside the definition of another class, which is the inner class.
Internal class is a very useful feature, but it is difficult to understand the use of it (I haven't used internal class much so far, and I only know a little about internal class).
First meeting
Internal classes are very easy to understand from the outside. It is nothing more than defining a class inside a class.
public class OuterClass {
private String name ;
private int age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
class InnerClass{
public InnerClass(){
name = "chenssy";
age = 23;
}
}
}
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
二维码
