Welcome to Westonci.ca, the place where your questions are answered by a community of knowledgeable contributors. Find reliable answers to your questions from a wide community of knowledgeable experts on our user-friendly Q&A platform. Get quick and reliable solutions to your questions from a community of experienced experts on our platform.
Sagot :
public class MyClass {
public static String monthName(int num){
String arr[] = {"January", "February", "March", "April", "May", "June", "July","August", "September", "October", "November", "December"};
return arr[num-1];
}
public static void main(String args[]) {
System.out.println(monthName(8));
}
}
I hope this helps.
Methods are blocks of named statements that can be called from other place in the program
The method in java, where comments are used to explain each line is as follows:
//This defines the method
public static void monthName(int month){
//This initializes the array of months
String months[] = {"January", "February", "March", "April", "May", "June", "July","August", "September", "October", "November", "December"};
//This prints the month name
System.out.print(months[month-1]); }
Read more about similar programs at:
https://brainly.com/question/22589115
Thanks for stopping by. We strive to provide the best answers for all your questions. See you again soon. We appreciate your time. Please revisit us for more reliable answers to any questions you may have. Get the answers you need at Westonci.ca. Stay informed by returning for our latest expert advice.