// Months.java Copyright (c) 2005 Kari Laitinen // http://www.naturalprogramming.com // 2004-10-09 File created. // 2005-04-17 Last modification. // If you are a reader who also studies my C++ book, // please note that this program does not work exactly // the same way as months.cpp in the C++ book. // The C++ program uses pointers, and pointers are not // available in the Java programming language. class Months { public static void main( String[] not_in_use ) { String[] names_of_months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" } ; System.out.print( "\n The first month of year is " + names_of_months[ 0 ] + "." ) ; System.out.print( "\n\n The seventh month, " + names_of_months[ 6 ] + ", is named after Julius Caesar.\n" ) ; System.out.print( "\n Our calendar has " + names_of_months.length + " months. \n" ) ; for ( int month_index = 0 ; month_index < 4 ; month_index ++ ) { int number_of_letters_in_month_name = names_of_months[ month_index ].length() ; System.out.print( "\n " + names_of_months[ month_index ] + " is made of " + number_of_letters_in_month_name + " letters: " ) ; for ( int letter_index = 0 ; letter_index < number_of_letters_in_month_name ; letter_index ++ ) { System.out.print( " " + names_of_months[ month_index ].charAt( letter_index ) ) ; } } } } /* Multiline comment begins: The following array is to be used in an exercise related to Months.java: String[] history_of_months = { "month of Roman god Janus", // January "last month in Roman calendar", // February "month of Roman war god Mars", // March "month of Roman goddess Venus", // April "month of goddess Maia", // May "month of Roman goddess Juno", // June "month of Julius Caesar", // July "month of Emperor Augustus", // August "7th Roman month", // September "8th Roman month", // October "9th Roman month", // November "10th Roman month" } ; // December Mulitiline comment ends. */