hey guys i'm having some trouble working this out. The aim is to convert an int array like this {1, 2, 3, 4} by adding one to each element and printing it using an ENHANCED for loop, so it will look like this {2, 3, 4, 5}. This is what i got so far :
int myArr[] = {1, 2, 3, 4};
for (int i: myArr){
i =+1;
myWindow.writeOutLine(i);
}
Pretty sure that is not close, i'm unsure how to store the new value in the array and go to next.
解决方案
you can use separate index variable if you have to use enhanced loop.
int myArr[] = {1, 2, 3, 4};
int count = 0 ;
for (int i: myArr){
myArr[count] = i+1;
myWindow.writeOutLine(myArr[count]);
count++;
}