Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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