When i run this code the output is "String"; if I hide the method that accepts a String parameter and run the code again then the output is "Object", so can anyone please explain 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);
}
}