+ 1
If overriding a method is the same as making a new one, why use overriding in the first place?
2 Antworten
+ 2
all the benefits of developing is to be able to use code several times without rewriting it.
moreover sometimes the initial method is in a library and you don't have the source code. so you can just override it.
+ 2
Yes, it is all about encapsulation and code reusability. I can change the way pre-written code and classes are going to operate by overriding a method in a parent class. Sometimes we override things built into Java as well like creating our own toString() methods etc...