Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

catch and try

 
Jello Yao
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it legal for a source file which only have try and without any catch blocks?
Thanks!
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried?
IIRC, a try block needs to be followed by at least one catch *or* finally block, but I might be wrong...
 
cornel jew
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
The best way is do some coding and let the compiler answer your question.
 
Robbie shi
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that is illegal~~
each try block should match a catch block
and the finalize block is optional
--
Robbies
-----------------------------
1.java IDE tool : JawaBeginer
2.Java Jar tool : JavaJar
http://www.pivotonic.com
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ilja recalled correctly. A try block must have an associated catch or finally block. So, the catch block is also optional.
As mentioned, the compiler is one of the best ways to discover such requirements of the language.
 
Raj Neets
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai
A try block must have either finally or catch block or both .Else it will give compile time error.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic