This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes The try block Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "The try block" Watch "The try block" New topic

The try block

Vlada Den
Ranch Hand

Joined: Dec 19, 2004
Posts: 32

Is it possible to use try on a single statement?


Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

Originally posted by Vlada Den:

Right back atcha!

Sure, it's possible.

Junilu - [How to Ask Questions] [How to Answer Questions]
Vlada Den
Ranch Hand

Joined: Dec 19, 2004
Posts: 32
Thank you , Junilu.

I've just tried it out and it worked. But in my texbook "Java 2: The Complete Reference" it says, that you can't use try on a single statement.

Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
I think you have misread something.
The book must have told you, that try cant be used alone without a catch or finally

Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
I agree. Here's the link:
subject: The try block
It's not a secret anymore!