Java Example | ||
String[] months = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; int monthIndex = 3; String thisMonth = months[monthIndex]; System.out.println("This month is: " + thisMonth); //use the length attribute to get the number //of elements in an array for(int i = 0; i < months.length; i++ ) { System.out.println("month: " + month[i]); } |
||