声明两个变量,其名称与其在超类中声明的名称相同
class MySuper { protected int num = 100; protected String name = "Edith";/*来 自 n o w j a v a . c o m*/ } class MySub extends MySuper { // Hides num field in MySuper class private int num = 200; // Hides name field in MySuper class private String name = "Mary"; public void print() { System.out.println("num: " + num); System.out.println("name: " + name); }/**nowjava - 时 代 Java**/ } public class Main {