The program is meant to invert the values in the array. When the program is run, the only values that show are 3 and 2, then it ends. I've been looking online but I can't figure out why this happens. Switching val[i] for temp in the SOP gives values of 0 and 1 then ends.
int[] val = {0, 1, 2, 3};
int temp;
for(int i=0;i<val.length/2;i++)
{
temp=val[i];
val[i]=val[val.length - 1 - i];
val[val.length - 1 - i]=temp;
System.out.println(val[i]);
}