why继承q 变量不能继承吗? 为什么不报错
package practice;
public class Why extends Q{
int a = 10;
void show() {
System.out.println(a);
}
public static void main(String[] args) {
Why w = new Why();
w.show();
}
}
class Q{
int a = 0;
}
package practice;
public class Why extends Q{
int a = 10;
void show() {
System.out.println(a);
}
public static void main(String[] args) {
Why w = new Why();
w.show();
}
}
class Q{
int a = 0;
}
2018-04-28
举报