Java – the difference between 2D arrays

I want to know the difference between these loops in a 2D array:

for (int r = row - 1,c = column - 1; r >= 0 && c >= 0; r--,c--) {
    ...
}


for(int r=row-1;r>=0;r--){    
    for(int c=column-1;c>=0;c--){
        ...
    }
}

Solution

for (int r = row - 1,c--)
for (int r = row - 1,c--)

The first example is a loop that decrements R and C in each loop, which means that the indexes R and C will draw diagonals from the array [row-1] [column-1]

for(int r=row-1;r>=0;r--){
    for(int c=column-1;c>=0;c--){

The second example calls a loop for each row index, so it will access all index arrays [R] [C]

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>