Created
September 11, 2017 17:14
-
-
Save kubukoz/74fb5ef4b0b8cd61be7562ae3f0733d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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