Errelion Errelion - 6 months ago 90
Java Question

Increment index of reference

I've got an integer that refers to a value stored in an array. How can i increment the index it refers to?

int[] pos={0,1,2};
int thisPos=pos[1];
thisPos=pos[++]; //-> thisPos=pos[2];


You need to declare the index separately:

int index = 1;
int thisPos = pos[index];
thisPos = pos[index];