Why do we essentially need polymorphism in java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why do we essentially need polymorphism in java?

I understand what polymorphism is but I could not understand how much useful it could be in practical programming, any suggestions?

10th Jun 2018, 12:52 AM
Sugar Ray Imran
2 Answers
+ 2
if you think inheritance is useful then you might know that polymorphism can make inheritance more important if u don't consider it important by itself.
10th Jun 2018, 12:53 AM
Sugar Ray Imran
+ 12
It is useful in practical programming, as in: you will use it everyday. Basically, polymorphism makes you reuse your code, instead of repeating yourself. Search for dry principle on the internet or scan the famous design patterns of the gang of four (some have also been added in the course section) to learn more about it. You'll see it everywhere when you proceed. If you have any particular question about polymorphism, just ask.
10th Jun 2018, 1:24 AM
Tashi N
Tashi N - avatar