Skip to content

Instantly share code, notes, and snippets.

@onegrx
Created March 30, 2016 13:48
Show Gist options
  • Select an option

  • Save onegrx/54ecd48d89b2bf02bd88f264c4d9f10e to your computer and use it in GitHub Desktop.

Select an option

Save onegrx/54ecd48d89b2bf02bd88f264c4d9f10e to your computer and use it in GitHub Desktop.
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