Quantcast
Channel: How to do method overloading for null argument? - Stack Overflow
Viewing all articles
Browse latest Browse all 8

How to do method overloading for null argument?

$
0
0

I have added three methods with parameters:

public static  void doSomething(Object obj) {    System.out.println("Object called");}public static  void doSomething(char[] obj) {    System.out.println("Array called");}public static  void doSomething(Integer obj) {    System.out.println("Integer called");}

When I am calling doSomething(null) , then compiler throws error as ambiguous methods. So is the issue because Integer and char[] methods or Integer and Object methods?


Viewing all articles
Browse latest Browse all 8

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>