The fixed-size arrays we were interested by until now were uni-dimensional arrays. They allowed us to store simple sequences of values. In some situations, it is necessary to resort to arrays that have greater dimensions. Let's illustrate this with a concrete example. Let's assume for example that I want to store the different grades obtained at the different written assignments in the context of this course for a single student. So here, I can use a one-dimensional array that I would name "notes" [= "grades"] and that would contain, for each of its entries, a grade of one written assignment. So here we would have the grade of the assignment 0, so the first assignment. here we would have the grade of the assignment 1, etc. So here I manage to count in a satisfactory way, the grades of a single student to the different assignments that he accomplished in the context of this course. Now let's assume that I want to take into account not only the grades of a single student but of all the students following the course. At that moment, I would need to use a two-dimensional array here, where the first dimension, which is the lines here, would correspond to a student. So here I would have the first student of the course. And every column would in fact represent all the grades obtained for one given assignments by all the students. So here for example, I would have the grades for the first assignment, and here the grade of the last assignment. So here I see that I need to resort to a more complex data structure, a two-dimensional array where the lines correspond to the students and the columns correspond to the assignments. Multidimensional arrays correspond exactly to this need. In Java, a two-dimensional fixed-size array is no more than an array of arrays. In reality, it's a little more complex than that because we know that in Java, arrays are manipulated through references. So the more correct diagram would be something looking like this: in every cell, we have a reference to an array. So the diagram you have here in front of you corresponds in fact to a structure that looks like this in Java. It's indeed an array of arrays. Concerning the syntax, adding a supplenmntary dimension to an array in Java is simply equivalent to adding another level of brackets. Here you have two concrete examples. Now let's have a better look at one of these examples. Here, I declare a two-dimensional array, I have two levels of brackets, which homogeneously contains integers and which is named "score". It's a two-dimensional array, so I'll initialize it with a construction that is analogous to what I know concerning one- dimensional arrays. Here I have a number of lines, which corresponds to a number of players, say for example that I have no more than 3 players by which I am interested. And regarding columns; a given number of columns which correspond to a number of games played by the players. So let's say, for example, that I have no more than 4. The purpose of the array "score" is to count the score obtained at every game by each player. So concretely, what structure am I going to have after such a declaration? Well here I declared an array with 3 entries, which translates into this, so every entry is itself an array with 4 entries; which can schematically translate into this. So here, for the entry "i", I have an array that can contain at most 4 entries, and each entry corresponds to a score. So this allows me to record the score obtained at every game for every player. So if I want to access the i-th player, I iterate over the first dimension. Once I accessed this dimension, I can access the second dimension which will give me the different scores obtained at the different games. So schematically, I can represent this with a two-dimensional array, So here I'd have an array with 3 lines and 4 columns. So every line "i" corresponds to a player, and this would be the line of the player i. And each column "j" corresponds in reality to all the scores for the game j. So if I want to know the score obtained by the player i when he played the game j, I need to access this cell of the two-dimensional array. The score for each game are in reality integers, which explains why I declared my two-dimensional array as an array of integers. If I know all the array's values when I'm declaring it, it's possible to initialize it at the time of declaration with a trick of this nature that looks a lot like what we did for unidimensional arrays. Of course, you need to specify as many values a there are dimensions, and that is for each dimension. What you are looking at corresponds to an array with 4 lines. And we can see that every line corresponds to an array, and that the number of columns isn't necessarily the same, in Java, for each line. So we can absolutely construct an array that looks like this, where we have a different number of columns for each line. We see indeed that we are dealing with an array of arrays. Each individual entry of the first array corresponds to an array. The indexation mechanism that allows me to access the different values of the array has the exact same signification as the uni-dimensional arrays. Here for example, if I access "array of [2]", I'm trying to access the elements of the first level of this array. So here, knowing that the elements are numbered from 0 to "size - 1", here I have the element of index 0, of index 1, of index 2, so when I access the element of index 2, I'm precisely getting this array, which I can find again here. So knowing that "array[2]" is itself and array, I can now access its j-th cell with the second index. So here, knowing that the indexes are once again numbered from 0 to "size - 1", the element of index 1 will be this one; which corresponds to this in the diagram, and to this element in my declaration/initialization. So to sum up the discussion we have just had, if we know what elements to put in the array beforehand, when we declare it, it is possible to initialize it like this. What we saw in the previous example, is that the elements of the first dimension are all arrays. In this instance, they're arrays of integer values. So concretely, in the example you are looking at, you have an array of 3 arrays: y[0], y[1], y[2]. The array y[0] is this array. The array y[2] is this last array. To access the elements of the second dimension, I add a level of brackets, and obviously, at that moment, the accessed value is an integer and not an array anymore. For example, if I want to access this element "y[1][1]", I first have to get the array y[1], which is this one, then I access the element of index 1, which is this one, so here I get the value 4. In the most general case, when we know the values to put in the array beforehand, we'll simply reserve the necessary memory locations when initializing, like in the uni-dimensional array case. So concretely, here, we'll end up with the construction of an array that contains 3 lines and each line contains 2 elements, that's the structure we'll end up with in memoery. And we saw that there exists default values for the initialization of these values in Java. So the values are the same as for the uni-dimensional arrays, so here I'll have zeroes everywhere, as they're integers. Then we need to proceed with an ad-hoc, manual, filling. Here I do it very explicitly by accessing cell by cell and by putting a value into it, so here I'll put 1 and I'll put 2 here, and so one. And we can of course imagine that it's very fastidious to proceed like this if we have very large arrays; which naturally makes us think about loops and the notion of iteration. How would we proceed if we want to iterate over a two-dimensional array, or more? The most natural way to iterate over a two-dimensional array is to nest two for-loops. The first for-loop will allow us to iterate over the entire set of lines of the array, so concretely, here, would allow us to iterate over each of these lines, so to iterate over each of these lines alterantely. The second index, the second loop, will allow us to iterate over all the colzumns of each line. So here, for each line, we want to iterate over each column. That's why the two loops are in reality nested. It's because for each "i", we want to iterate over all the possible "j"s. Notice especialy the looping conditions. So the number of lines obviously stops at "array's size - 1", which corresponds to this notation. And the second loop condition corresponds to the size of the entry "i" of the array, which correponds to this notation. You now know the essential about fixed-size arrays in Java. We studied the cases of uni-dimensional arrays, and two-dimenisonal arrays. It is of course possible to go beyond and have arrays of even bigger dimensions, even if we rarely go over 4 in practice. The use stays exactly the same as for two-dimensional arrays. To complete our study of arrays, we still have to see, in a following episode, the case of dynamic arrays, which we'll present shortly.