28 lines
550 B
Java
28 lines
550 B
Java
|
//: innerclasses/BigEgg.java
|
|||
|
// <20>2015 MindView LLC: see Copyright.txt
|
|||
|
// An inner class cannot be overriden like a method.
|
|||
|
import static com.mindviewinc.util.Print.*;
|
|||
|
|
|||
|
class Egg {
|
|||
|
private Yolk y;
|
|||
|
protected class Yolk {
|
|||
|
public Yolk() { print("Egg.Yolk()"); }
|
|||
|
}
|
|||
|
public Egg() {
|
|||
|
print("New Egg()");
|
|||
|
y = new Yolk();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public class BigEgg extends Egg {
|
|||
|
public class Yolk {
|
|||
|
public Yolk() { print("BigEgg.Yolk()"); }
|
|||
|
}
|
|||
|
public static void main(String[] args) {
|
|||
|
new BigEgg();
|
|||
|
}
|
|||
|
} /* Output:
|
|||
|
New Egg()
|
|||
|
Egg.Yolk()
|
|||
|
*///:~
|