A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Certification
»
Programmer Certification (SCJP/OCPJP)
Author
problem with catch and finally
Angela lewis
Ranch Hand
Joined: Mar 01, 2004
Posts: 100
posted
May 29, 2004 04:06:00
0
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
Joined: May 16, 2004
Posts: 187
posted
May 29, 2004 05:44:00
0
Something seems to be wrong with the question (I think)?
Looluo Zhu
Greenhorn
Joined: Nov 26, 2003
Posts: 8
posted
May 30, 2004 02:11:00
0
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
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: problem with catch and finally
Similar Threads
static methods
Doubt regarding FileInputStream
exCeption
Exceptions
try catch block
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter