Errelion Errelion - 1 year ago 134
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];

Answer Source

You need to declare the index separately:

int index = 1;
int thisPos = pos[index];
thisPos = pos[index];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download