* Objects are smart enough to be dynamic. Specifically, have the capacity to react differently depending on the situation .
* This is important because it makes the API reliable and easy to understand for the next developer .
* Here is an example. Suppose you have a method called “print ()”.
* The first question you could ask is, ‘what does this method of printing images, text, or what ?”
* Well using “polymorphism”, an object can be done to handle any situation with the same method name. Therefore, depending on what the object is called on the press, it will be able to print .
* Instead of having separate methods as PrintPictures (), printLetters (), and printNumbers () that has a unified print () and the object itself determines how to handle different types of situations .
< > In a nutshell, polymorphism is improved method call. In short, through inheritance and flow of Animal / mammals / Cat example :
void test ()
Simon = new Cat Cat creature Animal ();
= Simon / / upcasting < > Creature.eat () / / = Cat.eat
= new Dog Dog Rover ();
/ / Rover safe upcast reference to animals
void feed (Animal )
/ / Creature.eat () = Cat.eat ()
/ / feed (rover) = Dog.eat ()
/ / feed (Simon ) = Cat.eat ()
In this case, Animal.eat () is polymorphic .
Polymorphism: “Calling a Java / virtual method using a superclass reference to a more generalized real object invokes a method in the real object (the most specific subclass), using a bottom-up search mechanism “.
Tutorial Java, the definition of polymorphism indicates that the name of the function of overload is the same thing, which is an incorrect statement “.