This is polymorphism, you have now redefined the method, when you call this method on this object, even if it is applied to the superclass, the child-most method is called.
However, an example of where the increase occurs matters:
class MyClass { static void doSomething(Apple apple) { System.out.println("Apple"); } static void doSomething(RedApple apple) { System.out.println("RedApple"); } } ... RedApple apple = new RedApple(); MyClass.doSomething(apple); MyClass.doSomething((Apple)apple);
Output:
RedApple Apple
Since we upgrade it to Apple, the best matching method is the one that has the Apple parameter.
source share