0

The difference between method overloading and metgod overriding

21st Aug 2017, 5:24 AM
shikhar gupta
shikhar gupta - avatar
2 Respostas
+ 3
Overriding means that a subclasses overrides a method for it's uses, overloading means that there's a method with the same name as another, but taking other arguments. Overriding: class Animal{ public void say (){ System.out.println("Hi"); } } class Dog extends Animal { @Override public void say (){ System.out.println("Woof"): } } Overloading: class Main { public void say (){ System.out.println("Hi"); } public void say(String s){ System.out.println(s); } }
21st Aug 2017, 5:31 AM
Jonas Schröter
Jonas Schröter - avatar
+ 2
here is an example that you may want to check to see difference or understand the meanings of overriding and overloading https://code.sololearn.com/c0awDMpDLukF/?ref=app
11th Sep 2017, 3:07 PM
Melih Melik Sonmez
Melih Melik Sonmez - avatar