14 videos
80 minutes
Well, after seeing what a, Arrays, the next step is to see what is a two-dimensional array, we will see the two dimensions, not go on, but I will explain how to make more dimensions, and to understand how, are useful this element between the dies, we will continue with the example we are seeing so far, and I will explain in what cases might be useful, look! We are seeing that we have a train, and we have said that we will
have a Arrays for each wagon save how many passengers inside, right ?, that way she is as if we have several variables into one, with single name, with that Arrays, now say that besides I know what I have passengers in each car, I also want to know how many seats there are in each car, for himself calculate what percentage is busy ?, what are freed me ?, what sites people feel more ?, in order to make calculations, I need
namely, apart from how many passengers there are, how many seats also know I have, what would you do then? Another, Arrays, read different number of seats? and Would you have on the one hand, Arrays, with passengers? And on the other hand, Arrays, with seats? I could do it, but ... it would be more complicated, would have to have two, Arrays, independent, you better have all this information in one name, that's a, Matrix, a set of, Arrays, so while
a, Arrays, is a set of variables, a, Matrix, is a set of, Arrays, which in turn will be a much larger set of variables, but is primarily a set of, Arrays, how arrays are created? Well, look! Like, Arrays, here we put these brackets, they say here we will have several variables in one, because if I put other brackets, here we will say that we have a Arrays, Arrays, thus this
is a matrix, and in the same way that one, Arrays, had to say first, what will be the number of variables, we have a direction here there were five, here we come! In this direction, because in this case we have to indicate how many, Arrays, we will have in the other direction, ie, as is here, we could put, each of these variables, here create another, Arrays, and extend over each of these, another set of variables, as well as
is here, I created and say +, in this case I added two directions, see? Two variables in this direction, if here put a 2 this corresponds to this, so here to make us understand, this column is zero position, and this one would be the position 1, thus here I already have my womb, two dimensions of five by two, are the dimensions of this matrix, five two, which is what I've created, five times two, and now, I just
to save the data in each of these coordinates, so for example, if I want to use the first column, column zero to say how many seats there, and then column 1 to say how many passengers sitting there, and it would be very simple, it is as if we understood as follows, in the wagon number three, which is the index 2, the coordinate zero can say how many there are seats, and the one many are busy in the car number 4, which is
coordinate number three in column zero, I say how many seats there, and how many column one are busy, so I already administer and decide that the first column. I will use it to specify the number of seats and the second to specify the number of passengers, How is this done? Well what and would, for example, if I put this here, say, in the first car, the number of seats is 25, I've put here, and if I want, say how many
passengers there, because then what I refer, is now the second index, as I say are occupied by 20, and the same can do the following wagon, for example, we fill the last car, the last car we would say that this would be the last car, index 4, in the zero position, say many seats there, let's say that in this car more seats, there are 40 seats, and passengers are going to say, there are at 1, and we will keep it, and we will
say that there are 30 passengers, as would the other values, so these matrices, we can serve for many things, we can save, for example coordinates, which are widely used in board games, since in reality, this is like if we stopped a board of five by two, but if the game is 8 by 8, then here would create eight by eight, and have my matrix of 8 by 8, arrays are useful, are very necessary for many things, in the
we need to have data sets that are interrelated, not to have them in different arrays or independent variables, but all together so that there are combined under a single data structure, so the matrices have to dominate in the next video we will start see, Loops, work with examples of matrices, to make it easier to grasp this idea, which is very powerful in Java and you have to handle, and also
in the future I will try to put exercises matrices, for better grips wave. Okay! Let's move on.
About the Author
Biography: Analyst-Programmer in different languages. Tutor PREMIUM platforms recognized worldwide as CodigoFacilito. Editor Cristalab articles. My YouTube Channel is sponsored by the ANAYA and LaTostadora publisher. I like to explain in detail and give several examples for the avoidance of doubt.