#Looking for insight on how to make this cleaner; assigning days of the month with a jagged array.

1 messages · Page 1 of 1 (latest)

south elbow
#

I am making a method to store days of the month with a jagged array. I feel like this could be cleaner or there's a better way to use a nested for loop to do this?
``Java
int[][] daysOfMonth = new int [12][];

 daysOfMonth[0] = new int[31];
 daysOfMonth[1] = new int[28];
 daysOfMonth[2] = new int[31];
 daysOfMonth[3] = new int[30];       
 daysOfMonth[4] = new int[31];
 daysOfMonth[5] = new int[30];
 daysOfMonth[6] = new int[31];
 daysOfMonth[7] = new int[31];
 daysOfMonth[8] = new int[30];
 daysOfMonth[9] = new int[31];
 daysOfMonth[10] = new int[30];
 daysOfMonth[11] = new int[31];
 
 int day = 1;
 
 for(int i = 0; i <daysOfMonth.length; i++) {
  for(int j = 0; j < daysOfMonth[i].length; j++) {
     daysOfMonth[i][j] = day;
     day++;
  }
  day = 1;
 }

``

knotty turtle
dapper depot
#

yes, make a public class MonthVO {}