Originally posted by Rajasekhar Devi Reddy:
for(final int i : intarray){ } this is legal , but how is it possible for a fianl variable to change its value in each iteration??
It's really weird isn't it? The final keyword is to prevent the developer from changing the variable -- which technically he/she is not.
Interestingly, this is not normally done with a regular for loop, because it is common to change the index declared in the initialization expression (of the for loop), in the re-initialization expression (of the for loop).
Henry
[ January 10, 2008: Message edited by: Henry Wong ]