File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

For loop and Final Variables...

 
Abhijit Kolhatkar
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think, for each iteration of FOR loop, a new FINAL variable is created..
I got following excrept in the J2SE tutorial on SUN:
Notice how the code declares a local variable within the initialization expression. The scope of this variable extends from its declaration to the end of the block governed by the for statement, so it can be used in the termination and increment expressions as well.

I think, a new variable is created for each iteration..
 
Petrus Pelser
Ranch Hand
Posts: 132
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so it can be used in the termination and increment expressions as well.


Considering this statement, the variable can not be final.
 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,
are you talking about a for loop or a for-each loop?






Ah, yes there was this other thread.

Yours,
Bu.

[ October 09, 2006: Message edited by: Burkhard Hassel ]
[ October 09, 2006: Message edited by: Burkhard Hassel ]
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic