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

The (month - 1) that you've used inside the loop points to the month passed in the parameter in the function getDayNumber. Consider using .length function to calculate the length of the array. Try using for loop something like:
Your concept of how Array works is pretty clear! Just use months.length and you're good to go. Tell me how this works out for you!