This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Variable shadowing

 
Kaushal Shah
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"A variable declared within the for-loop can not shadow a local variable of the enclosing method."

Could anyone give me an exaplanation and an example for this one?

Cheers,
Kosh!
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compiling:



results in two errors: a is already defined in aMethod() and b is already defined in aMethod().
It's explained in Section 14.4.2 of the JLS
[ July 30, 2004: Message edited by: Barry Gaunt ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic