public class Test { public static void main(String[] args) { WhoAmI w = new One(); if (args.length > 0) { int i = Integer.parseInt(args[0]); if (i == 2) w = new Two(); else if (i == 3) w = new Three(); } w.whoAreYou(); } }