How does ambigous methods are resolved in java ?
Posted
by Jijoy
on Stack Overflow
See other posts from Stack Overflow
or by Jijoy
Published on 2010-04-09T14:50:00Z
Indexed on
2010/04/09
14:53 UTC
Read the original article
Hit count: 187
java
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
© Stack Overflow or respective owner