hai,
anyone pls explain why this happens? class superclass{
void method(int i){
System.out.println("Method 1");
}
void method(float a){
System.out.println("Method 2");
}
public static void main(
String args[]){
superclass sc = new superclass();
sc.method(1); // ok compiles and prints "Method 1"
subclass sub = new subclass();
sub.method(2); //line 2
}
}
class subclass extends superclass{
void method(long a){
System.out.println("child Method");
}
}
At line 2 compiler reports ambiguity of the methods. can u pls explain why it happens?