• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

please tell me.......................

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is exception handling?explain in detail?
 
Trailboss
Posts: 22954
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm moving this thread to "Java in General (beginner)"
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by PRATIBHA MATTA:
what is exception handling?explain in detail?


Please be specific as to what you want to know about exception handling. Any text book will give you a much more detailed description which no amount of messages can elucidate.
SJ
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi this is Kajol,
All i can tell u from ur question is that exceptions are the errors which occur because of errors in programming.....In order to overcome that, we use try catch methods.....
Hope this helps.....
Kajol
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello prathiba,
As kajol said, exception handling is a process of catching the errors in our code.
In detail:- Say the code which is developed will have to take in some int variables and if the input which is coming in is other than a int, the code will end up giving wrong results. so when data goes incorrect we have to handle it inside the program without allowing the program to abend or giving inproper results. for this try catch methods are used.
hope iam clear..
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,
Myself GOLU JAIN.
try {
to visualize 2 things :-
1)Error...which are inevitable .
and 2)Exception ....which can occur b'coz of some
unexpected reasons.
}
catch(IdeaException e){}
Errors are those things that are beyond the control of the
writter like "memory exhausted".
we cant handle errors but we can surely handle Exceptions
 
Sajan Joseph
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Pratibha,
Exception handling is a mechanism for handling errors in Java. It offers several advantages such as :
1) It separates the code for handling errors from the actual program code. This makes the program more readlbe and maintainable.
2) In Java exception handling is enforced by the compiler. The programmer is forced to handle any exceptional conditions generated by the program.
In Java all errors/ exceptions are objects. They inherit from a common super class called Throwable. Errors pertain to system errors like memory not available or JVM error which cannet be handled by the programmer under normal circumstances. Exceptions are conditions that occur due to programmer error or some kind of resource unavailability. For example if you are trying to read from a non existent file, then an exceptional condition is generated , which have to be dealt with or if you are trying to divide an integer by zero, then an arithmetic exception occurs which have to be handled.
Java uses the
try{
// some code
}catch(Exception e){
//some error handling code
}finally{
//This code is always executed
}
mechanism to handle exceptional conditions. During exceptional conditions the user can be alerted or a different path of execution can be under taken to solve the problem and avoid abnormal program termination.
I hope I have been able to convey he basic idea of exception handling to you.
Regards,
SJ
[This message has been edited by Sajan Joseph (edited January 08, 2001).]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pratibha,
Others have shown the structure of the try/catch...
try{
//some code
}
catch (exception e){
//some code
}
where "exception" is the type of exception you are trying to catch. There is a list of all of the existing exceptions in the java.lang API under Object/Throwable/Exception. A quick way to find out without looking at the API is to run your code with the try/catch commented out and see what exception the caommand line gives.
You can also create your own exceptions.
Hope the information is useful.
Sam Bode
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!