这两个private的地方不怎么明白,继承后是怎么调用的,求朋友解答一下。
- class ClassA{
- public ClassA(){
- System.out.println("ClassA()");
- }
- }
- class ClassB{
- public ClassB(){
- System.out.println("ClassB()");
- }
- }
- class ClassC extends ClassA{
- public ClassC(){
- System.out.println("ClassC()");
- }
- }
- class ClassD extends ClassB{
- [color=Blue]private[/color] ClassA ca = new ClassA();
- [color=Blue]private[/color] ClassC cc;
- public ClassD(){
- System.out.println("ClassD()");
- }
- public ClassD(int i){
- cc = new ClassC();
- System.out.println("ClassD(int)");
- }
- }
- public class TestConstructors{
- public static void main(String args[]){
- ClassD cd1 = new ClassD();
- ClassD cd2 = new ClassD(10);
- }
- }[color=Blue][/color]
复制代码 |
|