Не могу найти ответ на свой вопрос , я создаю одномерный массив с 4 клетками ( String season [] = new String [3]) под каждый вид сезона(их четыре), но компилятор выдает ошибку , что массив выходит за пределы (если поставить ... = new String [4]) все окей). В чем заключаются ошибка , если кто знает?
public class Solution {
public static void main(String[] args) {
checkSeason(12);
checkSeason(4);
checkSeason(7);
checkSeason(10);
}
public static void checkSeason(int month) {
String [] season = new String [3];
season [0] = "зима";
season [1] = "весна";
season [2] = "лето";
season [3] = "осень";
if (month == 12 || month == 1 || month == 2){
System.out.println(season [0]);
}
else if (month == 3 || month == 4 || month == 5) {
System.out.println(season [1]);
}
else if (month == 6 || month == 7 || month == 8) {
System.out.println(season[2]);
}
else if (month == 9 || month == 10 || month == 11) {
System.out.println(season [3]);
}
}
}