When writing loops like the ones below, is it best to use the value used to initialise the size of an array:
int n = foo();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
...
}
or use the length property on the array:
int n = foo();
int[] arr = new int[n];
for (int i = 0; i < arr.length; i++) {
...
}
Is it a matter of preference, or is there an advantage to one of them?