This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Why not legal java ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Why not legal java ?" Watch "Why not legal java ?" New topic

Why not legal java ?

Don Kiddick
Ranch Hand

Joined: Dec 12, 2002
Posts: 580

Joe Ess

Joined: Oct 29, 2001
Posts: 9024

Identifiers are only valid within the scope they are declared. You declared i within the synchronized block, it is not accessible outside of the block. There's a detailed explanation of scope in the Java Tutorial

[How To Ask Questions On JavaRanch]
subject: Why not legal java ?