Created
March 30, 2016 13:48
-
-
Save onegrx/54ecd48d89b2bf02bd88f264c4d9f10e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class Plane {} | |
| class Airbus extends Plane {} | |
| public class Main { | |
| void fly(Plane p) { | |
| System.out.println("I'm in a plane"); | |
| } | |
| void fly(Airbus a) { | |
| System.out.println("I'm in the best Airbus!"); | |
| } | |
| public static void main(String[] args) { | |
| Main m = new Main(); | |
| Plane plane = new Plane(); | |
| m.fly(plane); | |
| Airbus airbus = new Airbus(); | |
| m.fly(airbus); | |
| Plane planeAirbus = new Airbus(); | |
| m.fly(planeAirbus); | |
| } | |
| } | |
| /////////////// | |
| ////OUTPUT///// | |
| /////////////// | |
| I'm in a plane | |
| I'm in the best Airbus! | |
| I'm in a plane | |
| Process finished with exit code 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment