class ObjX { int i; void print () { System.out.println ("i=" + i); } } //end-ObjX public class DynamicExample5 { public static void main (String[] argv) { // Make space for 4 ObjX pointers. ObjX[] xArray = new ObjX [4]; // Make each of the 4 pointers point to ObjX instances. for (int k=0; k<4; k++) { xArray[k] = new ObjX (); } // Now assign data to some of them. xArray[0].i = 5; xArray[1].i = 6; // Print all. for (int k=0; k<4; k++) { xArray[k].print(); } } }