package com.iwit.test;
class Super {
int i = 0;
public Super(String s) {
i = 1;
}
}
class Demoa extends Super {
public Demoa(String s) {
super(s);
i = 2;
}
}
class Tests {
public static void main(String[] args) {
Demoa d = new Demoa("yes");// 编译失败。提示找不到构造函数,为什么?
System.out.println(d.i);
}
}
package com.iwit.test;
class Super {
int i = 0;
public Super(){
}
public Super(String s) {
i = 1;
}
}
class Demoa extends Super {
public Demoa(String s) {
i = 2;
}
}
class Tests {
public static void main(String[] args) {
Demoa d = new Demoa("yes");// 编译失败。提示找不到构造函数,为什么?
System.out.println(d.i);
}
}
|