asked 221k views
2 votes
Write Java statements to declare another array and initialize it with the names

of the months of the year

asked
User Abude
by
7.7k points

1 Answer

4 votes

Answer:

String[] months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

Step-by-step explanation: This code declares a String array named months and initializes it with the names of the twelve months of a year using curly braces {} and separating the values with commas. Each month name is enclosed in double quotes to indicate it is a string literal. Once this code is executed, the months array will contain the names of the months in order from January to December, and you can access each month by its index in the array, starting with months[0] for January and ending with months[11] for December.

answered
User Ryan Gill
by
8.4k points