Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Programmer Certification (OCPJP)
problem with catch and finally
Angela lewis
Ranch Hand
Posts: 100
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
public class Mine { public static void main(String argv[]){ Mine m=new Mine(); System.out.println(m.amethod()); } public int amethod() { try { FileInputStream dis=new FileInputStream("Hello.txt"); } catch (FileNotFoundException fne) { System.out.println("No such file found"); return -1; } catch(IOException ioe) { } finally{ System.out.println("Doing finally"); } return 0; } }
If Hello.txt does not exist then the output would be
No such file found
Doing finally
-1
Why isn't it
No such file found
Doing finally
-1
Thanks
Swamy Nathan
Ranch Hand
Posts: 187
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Something seems to be wrong with the question (I think)?
Looluo Zhu
Greenhorn
Posts: 8
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I think the question should be
No such file found
Doing finally
0
Why isn't it
No such file found
Doing finally
-1
and
this thread
has the answer.
SCJP 1.4
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Exceptions
exCeption
try catch block
Doubt regarding FileInputStream
static methods
More...