Skip to content

Instantly share code, notes, and snippets.

@kubukoz
Created September 11, 2017 17:14
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 kubukoz/74fb5ef4b0b8cd61be7562ae3f0733d7 to your computer and use it in GitHub Desktop.
Save kubukoz/74fb5ef4b0b8cd61be7562ae3f0733d7 to your computer and use it in GitHub Desktop.
public class Sample {
public static void main(String[] args) {
new Dog().speak(10); //I am 10
new Dog().speak("kek"); //I am kek wow
}
}
class Animal {
void speak(Object something){
System.out.println("I am " + something);
}
}
class Dog extends Animal {
void speak(String name) {
((Animal)this).speak(name + " wow");
//ewentualnie to samo:
this.speak((Object) (name + " wow"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment