aspose file tools*
The moose likes Beginning Java and the fly likes try statement variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "try statement variables" Watch "try statement variables" New topic

try statement variables

Eric Giblock

Joined: Nov 19, 2003
Posts: 4
int variable 1
int variable 2.

how can i access the values of the variables inside the try statement from outside the try statement??

-- Eric
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24187

Hi Eric,

You can't. You can move the declarations outside the try block:

Note that you may have to initialize the variables when they're declared, or the compiler may complain that the variables "may not have been initialized" when you access them in the catch block.

[Jess in Action][AskingGoodQuestions]
wood burning stoves
subject: try statement variables