Skip to content

Instantly share code, notes, and snippets.

@rajeevprasanna
Created January 19, 2014 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajeevprasanna/8500874 to your computer and use it in GitHub Desktop.
Save rajeevprasanna/8500874 to your computer and use it in GitHub Desktop.
overloading without overriding
package polymorphism.overloadingWithoutOverriding;
public class Bar extends Foo {
// Don’t be fooled by a method that’s overloaded but not overridden by a
// subclass. It’s perfectly legal to do the following:
void doStuff(String s) {
}
// The Bar class has two doStuff() methods: the no-arg version it inherits
// from Foo (and does not override), and the overloaded doStuff(String s)
// defined in the Bar class. Code with a reference to a Foo can invoke only
// the no-arg version, but code with a reference to a Bar can invoke either
// of the overloaded versions.
}
package polymorphism.overloadingWithoutOverriding;
public class Foo {
void doStuff() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment