题解 | #类型判断#
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
String className = scanner.next();
Base obj = (Base) Class.forName(className).newInstance();
System.out.println(getClassName(obj));
}
}
public static String getClassName(Base obj) {
//write your code here......
return obj.getClass().getName();//莫名其妙,写了一行居然就过了,本来面向对象这块学的不好,以为还要看答案才能做出来。。。
}
}
class Base {
}
class Sub1 extends Base {
}
class Sub2 extends Base {
}