【发布时间】:2021-11-26 03:14:40
【问题描述】:
public class Array {
public static void main(String args[]) {
String[] months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
int[] daysInMonth = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
System.out.println("There are a total of " + daysInMonth[0] + " days in the month of " + months[0] + ".");
}
}
我不是每个月打印到控制台 12 次不同的时间,而是如何提高我的代码效率并创建一个循环来打印出数组中的每个元素?
【问题讨论】: