I have this class BindingSample with a method that takes no parameter
public class BindingSample {
public void printMsg(){
System.out.println("Binding Sample no parameter");
}
}
And another class that extends the BindingSample and uses the same method signature but adds a parameter to it
public class application extends BindingSample {
public void printMsg(int i){
System.out.println("Changed my value " + i);
}
public static void main(String[] args) {
application app = new application();
app.printMsg(5);
}
}
The output is Changed my value 5
Why did it work even if the parameters are different? And why is it called overloading? I don't think it's overriding because to override a method, the method signature and its parameter should be the same.