Everytime I run the code I get an Index 12 out of bounds for length 12. I'm not sure what is the problem. Here is the code:
enter code here: int getDayNumber(int day,int month,int year) {
if(this.leapYear(year)) {
int months[] = {31,29,31,30,31,30,31,31,30,31,30,31};
int cnt = 0 ;
for(int i=0;i<month-1;i++) {
cnt += months[i];
System.out.println(cnt + " " + i);
}
return cnt + day ; // count = cnt