面试官让我解释这段代码。它做了什么?
public class Test {
public void methodOne(Object obj) {
System.out.println("Object as Parameter");
}
public void methodOne(String str) {
System.out.println("String as parameter");
}
public static void main(String[] args) {
Test t = new Test();
t.methodOne(new Object());
t.methodOne("");
t.methodOne(null);
}
}
答案 0 :(得分:0)
$ java -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
和
$ javac Test.java
$ java Test
Object as Parameter
String as parameter
String as parameter