Can you understand that?
aux[counter] = aux[counter] + 1;
It is the same thing. It takes the value of the element indicated by counter
of array aux
, adds 1 and stores in the same location, evidently changing the value of this variable.
The counter++
only sum 1 to variable counter
, It doesn’t do anything else. There’s no magic. There’s nothing like "bounce houses" or anything like that. The operator always works on the variable being applied, it doesn’t work on other things elsewhere. The vector is one thing and the counter is another, by chance at a certain time they are used together to obtain a result.
The term "bounce houses" there seems to me poorly employed. The counter
is a variable, and aux
is another, are different things. The variable aux
has a special situation, it does not have a single value, it has several. We usually call each of these values elements (some people give other names, like items, for example, but you have to be careful not to give names that indicate something else that is not). The elements of aux
are accessed by a numerical index starting at zero for the first element up to a number before the size of the vector (since it starts from zero and not from one). How you will access in memory is a problem that in Java you do not need to know, just think abstractly.
You do not skip houses, you access an element by a number. This number can be a literal or a variable that will indicate its value. The access to the vector is random, so access what you want, is not sequence to jump anything.
If you don’t know what value to put on the table test you are probably doing the test wrong.
Table test is to follow the sequence of code execution as if it were the computer and have columns (or another form of organization) for each variable and then annotate the value of the variable whenever it changes. You know that the current value is always the last, This should simulate the computer memory.
Some people prefer to use a grid and repeat the value of all variables on each line, whether they have changed it or not. In general this "requires" a marking to indicate better when there has been change or not.
You may be thinking about how to control the values of the elements of the vector, it is simple: consider each element as a single variable, because at the bottom it is that, are several variables with the same name and an index to differentiate them. You’ll have to put their names in the header: aux[0] | aux[1] | etc.
.
The current value of the counter will be used to determine which column you will move. If the counter is 1, it will move the variable aux[1]
, when you have to access to read or to change a value of aux
, you have to look at the counter value, if it is 2, for example, you know you will manipulate the column aux[2]
. Simple as that.
Has a table test example.
Oh understood, thank you... Very good explanation. I will try to do here. ;)
– Marcielli Oliveira