I would like to know how array[array[i]]++ works in java. I wrote the code, and want to know how this count integer array is working here

int[] counts = new int[201];
        for (int i = 0; i < d; i++) {
            counts[array_inside[i]]++;
}

and also would like to know if i does like below how count array values will be written and left or right shift its values

for(int i = j; i < array_inside.length; i++){
count[array_inside[i-j]]--;
            count[array_inside[i]]++;
}

1 Answers

2
Elliott Frisch On

Consider it as two operations (because it is). This

counts[array_inside[i]]++;

is equivalent to

int p = array_inside[i];
counts[p]++;