I would like to minimize the scope of arr
to a do ... while
loop, so it can be destroyed once the loop is exited.
If I declare arr
within the do while
loop, I get the error:
symbol cannot be found
I can declare it right before the cycle, but then I keep bloated arr
in memory even though I don't need it any more.
//int[] arr = {0}; // this works, but the scope is outside the loop
do {
int[] arr = {0}; // causes "cannot find symbol" on `while` line
arr = evolve(arr); // modifies array, saves relevant results elsewhere
} while (arr.length < 9999);
What is the correct way to deal with this situation?