When I run this code, the output will be "String"; if I hide the method that takes the String parameter and runs the code again, then the output will be "Object", so can someone explain to me how this code works?
public class Example {
static void method(Object obj) {
System.out.println("Object");
}
static void method(String str) {
System.out.println("String");
}
public static void main(String args[]) {
method(null);
}
}
varun source
share