File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes compilation error in try/catch/finally Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "compilation error in try/catch/finally" Watch "compilation error in try/catch/finally" New topic
Author

compilation error in try/catch/finally

sonir shah
Ranch Hand

Joined: Nov 01, 2001
Posts: 435

I tried running the program, but it is giving some compilation error..
Can any one explain me why?? and what is wrong with the code?
Sonir
bill williams
Ranch Hand

Joined: Jan 15, 2002
Posts: 94
you need to catch the exception from the second tc.m1(). because it is not a runtimeexception


Yet Another SCJP2
Seany Iris
Ranch Hand

Joined: Jan 08, 2002
Posts: 54

Why cann't it compile. Who can explain it to me?Give the error:
TestClass.java:14: 'finally' without 'try'
finally { tc.m2(); }
^
1 error


help you means help me
Younes Essouabni
Ranch Hand

Joined: Jan 13, 2002
Posts: 479
What happened if you take off this ; in that line : catch (MyException d) { };
Hope that it helps and that it works!!!


Younes
By constantly trying one ends up succeeding. Thus: the more one fails the more one has a chance to succeed.
Younes Essouabni
Ranch Hand

Joined: Jan 13, 2002
Posts: 479
Originally posted by Seany Iris:

Why cann't it compile. Who can explain it to me?Give the error:
TestClass.java:14: 'finally' without 'try'
finally { tc.m2(); }
^
1 error

It doesn't compile because of the; after your catch, so that the compiler wonders where your finally comes from!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compilation error in try/catch/finally