public static Greeter getRandomInstance() { if (generator.nextBoolean()) // note: generator is static field return new Greeter("Mars"); else return new Greeter("Venus"); }
Invoke through class:
Greeter g = Greeter.getRandomInstance();
Static fields and methods
should be rare in OO programs