Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on varargs

 
victor kamat
Ranch Hand
Posts: 247
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider the following code:

This code compiles fine and puts out the expected output.
What has me confused is the "final" int the second for loop.
I would have thought that the code would not compile.
If we make k final in the 1st loop, code does not compile.
Can somebody explain this to me.
[ January 21, 2007: Message edited by: Barry Gaunt ]
 
victor kamat
Ranch Hand
Posts: 247
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have answered my own question. In the loop body cannot change value of i

void prt(int... par)
{
for(final int i : par)
{
// in loop body cannot change i
}
}
[ January 21, 2007: Message edited by: Barry Gaunt ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic