// Project: Patterns1 // Module: factory // Source code file Main.java // Illustrate the Factory software pattern // Make the constructor private so that objects // can only be obtained using // the static getInstance method. public class Main { public static void main(String[] args) { FactoryObject[ ] objects = new FactoryObject[20]; for(int i = 0; i < objects.length; i++) { objects[i] = FactoryObject.getInstance( ); } for(FactoryObject obj : objects) { System.out.print(obj + " "); } } }