//Our first array of objects. public class ArrayOfObjects1 { public static void main(String[] args) { Month[] a = new Month[12 + 1]; //Allow a[0] to remain null; let January have subscript 1. a[ 1] = new Month("January", 31); a[ 2] = new Month("February", 28); a[ 3] = new Month("March", 31); a[ 4] = new Month("April", 30); a[ 5] = new Month("May", 31); a[ 6] = new Month("June", 30); a[ 7] = new Month("July", 31); a[ 8] = new Month("August", 31); a[ 9] = new Month("September", 30); a[10] = new Month("October", 31); a[11] = new Month("November", 30); a[12] = 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; } };