caoguanghui
发贴: 14
积分: 0
|
于 2006-10-13 22:38
public class PrintClass { int x = 0; int y = 1;
void printMe() { System.out.println("x is " + x + ", y is " + y); System.out.println("I am an instance of the class " + super.getClass().getName()); } }
class PrintSubClass extends PrintClass { int z = 3;
public static void main(String[] arguments) { PrintSubClass obj = new PrintSubClass(); obj.printMe(); } } **************************************************************** javac PrintClass.java后 执行: java PrintSubClass 为什么输出结果是 I am an instance of the class PrintSubClass 而不是 I am an instance of the class PrintClass ?
|