This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Exception block scope 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 » Java » Beginning Java
Bookmark "Exception block scope" Watch "Exception block scope" New topic
Author

Exception block scope

Devendra Walanj
Greenhorn

Joined: Apr 21, 2010
Posts: 12
Hello I have a code as follows
1. Not working Code :

as you can see fore the the code will not compile

2. Working Code :


As you can see the difference in both the snippets that the placement of the psw object.
So want to know that when I created the PrintWriter object in the try block it's scope got limited it try block only.

Does this mean that object / variables defined in try block have their scope limit to that try block ?


Keep Moving Forward
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60783
    
  65

Yes. As with every other block. Why would try be different?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception block scope
 
Similar Threads
How to Change the File Name for Each Uploaded Files to the Socket Server?
threads concurrency problem
Problem integrating hibernate & EJB 3
socket not accepting data 2nd time
returned null;