jQuery in Action, 3rd edition
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

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: 24189

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]
Have you checked out Aspose?
subject: try statement variables
It's not a secret anymore!