public class Test{
public static void m1(Object o){
System.out.println("object called");
}
public static void m1(String s){
System.out.println("String called");
}
}
Now, here are the below cases,
- m1("string"); output : String called
- m1(new String("string")); output : String called
- Object o = "string"; m1(o); output : object called
- Object o = new String("string"); m1(o); output : object called
- Object o = new Object(); m1(o); output : object called
Can someone please explain the above scenarios?