wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Variable shadowing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Variable shadowing" Watch "Variable shadowing" New topic
Author

Variable shadowing

Kaushal Shah
Greenhorn

Joined: Jul 20, 2004
Posts: 4
"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

Joined: Aug 03, 2002
Posts: 7729
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 ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
Don't get me started about those stupid light bulbs.
 
subject: Variable shadowing
 
Similar Threads
WA #1.....word association
regard on k&b book
Home loans in India - fixed or floating ?
Running two threads
Dont declare global variables in Servlet