Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
Character[] array = new Character[10];
for(int i=0;i<array.length;i++) 
  array[i] = 'x';

for(int i=0;i<array.length;i++) 
  System.out.print(array[i]);  // prints 10 "x"s

Risk Assessment

Attempts to assign to the loop variable from within the enhanced for loop (for-each idiom) are futile and may leave the class in a fragile, inconsistent state.

...