- #1
grzz
- 1,021
- 21
- TL;DR Summary
- I cannot see why there are errors displayed in lines 22 and 23.
Java:
//program showing an advantage of using arrays
public class Arr3
{
public static void main(String []args)
{
System.out.println("There are 31 days in the month of Jan");
System.out.println("There are 27 days in the month of Feb");
System.out.println("There are 31 days in the month of Mar");
System.out.println("There are 30 days in the month of Apr");
System.out.println("There are 31 days in the month of May");
/*We can make use of an array with the number of days in the month
* and another array with the names of the months and use these two
* loops to go through these numbers of days and these names of
months*/
int mdays []={31, 37, 31,30, 31};
String months []={Jan, Feb, Mar, Apr, May};
for(i = 0; i < mdays.length; i++)
{
System.out.println("There are " + mdays[i] + " days in the month
of " + months[i]);
}
}
}
Please help me.
Thanks.
Last edited: