private static String getArgValue(String[] argsString, int[] jIndex, String classTag) {
String thisToken;
for( ; jIndex[0]<argsString.length ; jIndex[0]++) {
System.out.println("jIndex[0]: " + jIndex[0]);
if (condition) {
// yadda yadda yadda
jIndex[0]++;
System.out.println("jIndex[0]: " + jIndex[0]);
return retString;
}
}
return retString;
}
I’ve tried wrapping it both with Integer and with an array, but neither have made changes to the original i variable. How it is called:
int[] j = new int[1];
for(int i=2; i< argsString.length; i++) {
// yadda yadda yadda
System.out.println("opening i: " + i);
j[0] = i;
thisArgValueString = getArgValue(argsString, j, thisArgClassString);
System.out.println("closing i: " + i);
}
Example output:
opening i: 2
jIndex[0]: 2
jIndex[0]: 3
jIndex[0]: 5
closing i: 2
Try printing your int holder and not i itself:
Or you can simply reassign i:
Your original varialbe
iwill not change by itself as it is a primitive type. Integer is also not useful as it is immutable. So the code you provided is essentially the correct approach. You just have to understand, thatj[0] = ionly assigns the value ofitoj[0]and does not link the content ofj[0]toi. So you could just work withj[0]from that point on (like the first code in this post) or reassigniback fromj[0](like the second code in this post).