two dimensional array print
ok so i'm stuck with this problem.
Trying to print out a two dimensional array of a timetable(done) but on the right side, the day name has to be listed, but from another array.
This is what i'm aiming to print out
Code:
9 10 11 12 13 14 15 16
0 0 0 0 0 0 0 0 MONDAY
0 0 0 0 0 0 0 0 TUESDAY
0 0 0 0 0 0 0 0 WEDNESDAY
0 0 0 0 0 0 0 0 THURSDAY
0 0 0 0 0 0 0 0 FRIDAY
And this is what is what i'm getting
Code:
9 10 11 12 13 14 15 16
0 0 0 0 0 0 0 0 MondayTuesdayWednesdayThursdayFriday
0 0 0 0 0 0 0 0 MondayTuesdayWednesdayThursdayFriday
0 0 0 0 0 0 0 0 MondayTuesdayWednesdayThursdayFriday
0 0 0 0 0 0 0 0 MondayTuesdayWednesdayThursdayFriday
0 0 0 0 0 0 0 0 MondayTuesdayWednesdayThursdayFriday
I'm quite new to java and nesting and all this really confuses me :confused:
I have declared the arrays elsewhere.
Here is my current code:
Code:
public void printTable(){
int start, end, count;
end = 16;
count = 0;
System.out.println();
System.out.println("-----------------------");
for (start = 9; start <= end; start++){
System.out.print(start + " ");
}
for (int row = 0; row < timetable.length; row++){
System.out.println("");
for (int col = 0; col < timetable[row].length; col++){
System.out.print(timetable[row][col] + " ");
}
for (int i = 0; i< DAYS.length; i++) {
System.out.print(DAYS[i]);
}
}
System.out.println();
System.out.println("-----------------------");
}
Sorry about my variable names and indenting :o
It hasn't been specified whether I should use the DAYS array (containing the days) or just put in the days myself. I thought using the array would be easier..and now I'm not sure.
So if anyone could give me a pointer or know any good site/places i could learn more on this that would be great.