我在初始化数组时遇到问题。当我尝试绘制数组时,我得到了一个NullPointerException.
我需要访问我从另一个类声明数组的类,这就是为什么它是static.
这是我的代码:
static int[][] DayOfTheMonth = new int[3][10];
public static void ArrayValue() {
for (int column = 0; DayOfTheMonth.length < 4; column++) {
for (int row = 10; DayOfTheMonth[column].length < 10; row++) {
if (DaysofTheMonth <= Tag.MaximumDaysOfAMonth()) {
DayOfTheMonth.[column][row] = Date.getDate() + DaysofTheMonth;
DaysofTheMonth++;
} else if (DaysofTheMonth > Tag.MaxDay()) {
DaysofTheMonth = 1;
if (Month != 12)
Month++;
else {
Month = 0;
Year++;
}
}
}
}
}
另一个问题是,当我尝试通过我的主类访问该方法时,它说:
Exception in thread "Main" java.lang.ArrayIndexOutOfBoundsException: 3
翻阅古今
尚方宝剑之说
相关分类