Skip to content

Instantly share code, notes, and snippets.

@kevinpet
Created February 8, 2015 21:33
Show Gist options
  • Save kevinpet/f0ff497dd88537bfbf62 to your computer and use it in GitHub Desktop.
Save kevinpet/f0ff497dd88537bfbf62 to your computer and use it in GitHub Desktop.
OO Java
abstract class OoFoo {
abstract void handle();
static class Bar extends OoFoo {
private int bar;
private Bar(int bar) {
this.bar = bar;
}
@Override
void handle() {
System.out.println("I have " + bar + " bars");
}
}
static class Baz extends OoFoo {
private String baz;
private Baz(String baz) {
this.baz = baz;
}
@Override
void handle() {
System.out.println("I have the " + baz + " baz");
}
}
public static void main(String[] args) {
new Bar(42).handle();
new Baz("Luhrmann").handle();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment