0
 public class Simple{
     public static void main(String args[]){
         method(null);
     }
     public static void method(Object o) {
         System.out.println("Object" + o);
     }
     public static void method(String s) {
         System.out.println("String" + s);
     }
 }

Why above code snippet produces "Stringnull" output and not "Objectnull"?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • 2
    See answer: https://stackoverflow.com/questions/5229809/method-overloading-for-null-argument – Zinc Dec 05 '20 at 09:55
  • 3
    Does this answer your question? [Method Overloading for null argument](https://stackoverflow.com/questions/5229809/method-overloading-for-null-argument) – Zinc Dec 05 '20 at 09:58

0 Answers0