Skip to content

Instantly share code, notes, and snippets.

@dwins
Created February 27, 2013 14:04
Show Gist options
  • Save dwins/5048116 to your computer and use it in GitHub Desktop.
Save dwins/5048116 to your computer and use it in GitHub Desktop.
abstract class Printer {
public static String message;
}
class FormalPrinter extends Printer {
static {
message = "Why hello good sir!";
}
}
class CasualPrinter extends Printer {
static {
message = "Yo dawg what up?!";
}
}
public class Print {
public static void main(String[] args) {
FormalPrinter formalPrinter = new FormalPrinter();
CasualPrinter casualPrinter = new CasualPrinter();
System.out.println(formalPrinter.message);
System.out.println(casualPrinter.message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment