Jak działają przeciążone metody?
public class Test1 {
public static void main(String[] args) {
Test1 test1 = new Test1();
test1.testMethod(null);
}
public void testMethod(String s){
System.out.println("Inside String Method");
}
public void testMethod(Object o){
System.out.println("Inside Object Method");
}
}
Gdy próbuję uruchomić dany kod, otrzymuję następujące dane wyjściowe:
Inside String Method
Czy ktoś może wyjaśnić, dlaczego metoda zString
wywoływany jest parametr typu?