Tuesday, February 25, 2014

Output of the below program

public class StringTest {
    public static void main(String args[]){
        add(null);
    }
  
    public static void add(String s){
        System.out.println("String : I am in add method");
    }
    public static void add(StringBuffer s){
        System.out.println("StringBuffer : I am in add method");
    }
}

O/P : compile time error - The method add(String) is ambiguous for the type
     StringTest

No comments:

Post a Comment