Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What are exceptions?

Status
Not open for further replies.

glaserc

Programmer
Feb 16, 2001
34
US
i just got out of a lecture involving exceptions and my head is still spinning. Could someone please give me a brief explanation to what exceptions are and when they are used. thanks!
glaserc
 
So you want to know what the exceptions are actually ?

i laughed when i have gone throw the question for a moment.

Exception means in simple :-

Doing what you should not do .But still you do that unknowningly.

Let me be more clear.

Say you are doing operation a= b/c ( ie storing b divided by c in a);

but the values in b and c are taken while the programm is running and system will come to and end if c=0, ie don't even warn you why it ended.


So if you use exception called divideByZero then you can still continue the procedure jsut leaving that division.

So thus exception are used to warn you about the possible errors.

Hope you get it atleast an inch of this explanation.

If you want more details contact me in
ksriniva@cal.cognizant.com
 
Exceptions are a way to handle possible errors and the syntax is
try
{
// put whatever you want to happen. eg: A user has to enter some numbers in a text field and you only want numbers.
}
catch(Exception e)
{
//put an error message or whatever you want. For instance, if a user does not enter a message or enter some characters, display a message saying that he has to enter something in a text field or that he can only put numbers!!
}

I hope it will help you!!
Ousmane

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top