How does ambigous methods are resolved in java ?
- by Jijoy
Hi ,
I do have a question.
package org.study.algos;
public class Study {
public static void main(String[] args) {
A a = new A();
a.m1(null);
}
}
class A {
public void m1(String s) {
System.out.println("String");
System.out.println(s);
}
public void m1(Object obj) {
System.out.println("Object");
System.out.println(obj);
}
}
Here , the output is
String
null
Why JVM resolve the method to one with String arguement ?
Thanks in advance
J