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
Win a copy of
Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams
this week in the
Agile and Other Processes
forum!
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
Devaka Cooray
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Jeanne Boyarsky
Tim Cooke
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Tim Moores
Mikalai Zaikin
Carey Brown
Bartenders:
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
Think of how stupid the average person is. And how half of them are stupider than that. But who reads this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Exceptions
exCeption
try catch block
Doubt regarding FileInputStream
static methods
More...