//Simpler way to create the same array of objects. public class ArrayOfObjects2 { public static void main(String[] args) { Month[] a = { null, new Month("January", 31), new Month("February", 28), new Month("March", 31), new Month("April", 30), new Month("May", 31), new Month("June", 30), new Month("July", 31), new Month("August", 31), new Month("September", 30), new Month("October", 31), new Month("November", 30), new Month("December", 31) }; for (int i = 1; i < a.length; ++i) { System.out.println(i + "\t" + a[i]); //means System.out.println(i + "\t" + a[i].toString()); } System.exit(0); } } class Month { String name; int length; public Month(String name, int length) { this.name = name; this.length = length; } public String toString() { return "name == " + name + ", length == " + length; } };