I have code looks like this:
boolean[] array = new boolean[200];
int[] indexes = {10, 42, 62, 74};
while(true) {
//some code here
StringBuilder sb = new StringBuilder();
for (int j : indexes) {
sb.append(array[j] ? '1' : '0');
}
}
Bytecode for this:
ASTORE 3 //"indexes" array
...
ALOAD 3
ASTORE 8
ALOAD 8
ARRAYLENGTH
...
I am not sure about why javac copy ref to array into another local var.