Results 1 to 4 of 4
Thread: Try... Catch?
- 10-06-2011, 04:16 AM #1
Member
- Join Date
- Sep 2011
- Posts
- 10
- Rep Power
- 0
Try... Catch?
Consider this block of code:
Try {
Divide d = new Divide;
int result = d.div (5,0);
}
Catch (Exception e )
{
System.out.println ( e.getMessage( ) );
}
In this code, 10 will be divided by 0, which will surely yield an error.
My question would be:
1,
What is the "e" in the parenthesis that following the Catch keyword?
2, Just WHAT error would be passed to WHOM?
Will the error-dealing mechanism actually know what error it is in some more complicated situation, e.g. reading a file, then there won't be just one error, there could be disk suddenly removed, other program is using that file, no such file etc etc.
To rephrase my 2nd cluster of question and make it clearer:
Does the catch key word actually enables a mechanism that try to deal with a detailed error, or it just deal with an error, it doesn't care what it is?
If it does deal with a detailed one, how?
Posting tutorial links is also welcomed.
- 10-06-2011, 04:22 AM #2
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 11
Re: Try... Catch?
You might want to read this: Lesson: Exceptions (The Java™ Tutorials > Essential Classes)
And for future reference, bookmark this The Really Big Index
- 10-06-2011, 11:44 AM #3
Member
- Join Date
- Oct 2010
- Location
- Nagpur
- Posts
- 6
- Rep Power
- 0
Re: Try... Catch?
how to write?
please help me.
- 10-06-2011, 10:29 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
Re: Try... Catch?
First locate a pen or pencil. A pen or pencil is a pointy cylindrical shaped device. Put the pen or pencil between your thumb and index finger; keep the pointy side downwards because if you keep the pointy side in an upward position (while holding the pen or pencil between your thumb and index finger) and you have to sneeze, the consequences may be horrible. Put a piece of paper in a horizontal position, just underneath the pointy side of the pen or pencil. A table is an ideal support for this configuration. Now start moving your hand (the one holding the pen or pencil) in a slow motion from left to right while you make littly wiggly movements with your thumb and index finger. When the pointy side of the pen or pencil is going to scratch the surface of the table, move your hand (and pen or pencil) to the left side of the paper again.
Glad to have helped.
kind regards,
JosLast edited by JosAH; 10-06-2011 at 10:38 PM.
Build a wall around Donald Trump; I'll pay for it.
Similar Threads
-
try and catch
By Bimz in forum New To JavaReplies: 1Last Post: 09-26-2011, 10:44 AM -
try catch help
By vividcooper in forum New To JavaReplies: 8Last Post: 02-11-2010, 10:00 AM -
how to catch two exceptions in one catch()?
By arnab321 in forum New To JavaReplies: 1Last Post: 11-06-2008, 11:54 AM -
try catch...
By MarkWilson in forum New To JavaReplies: 8Last Post: 06-27-2008, 06:39 PM -
Use try and catch
By zoe in forum New To JavaReplies: 2Last Post: 07-25-2007, 08:50 PM
Bookmarks