Java in the internal classes and interfaces together, can be resolved often by C + + programmers complain that there is a problem in Java not much inheritance.
Each inner class can be inherited independently from one (interface) implementation, so no matter whether the outer class has inherited an (interface) implementation, it has no effect on the inner class.
1. Internal class inheritance
Because the constructor of an inner class must be connected to a reference to its outer class object, special syntax is used when inheriting the inner class. The problem is that a reference to a perimeter class object must be initialized, and there is no default object to connect to in the exported class. Therefore, it is necessary to use special grammar to make clear the relationship between them.
Class withinner{
class inner{}
} public
class Inheritinner extends withinner.inner{
Inheritinner ( Withinner WI) {
wi.super ();
}
}
2 Internal class coverage
When inheriting a peripheral class, the inner class does not change. Changes occur when an internal class is explicitly inherited.
public class Egg {
private yolk y;
Protected class Yolk {public
yolk () {
System.out.println ("Egg.yolk");
}
Public Egg () {
System.out.println ("New Egg");
y = new yolk ();
}
}
public class Bigegg extends Egg {public
class yolk {public
yolk () {
System.out.println ("Bigegg.yolk ()"); c3/>}
} public
static void Main (string[] args) {
new Bigegg ();
}
}
Output:
New Egg
Egg.yolk