SlideShare a Scribd company logo
1 of 5
Download to read offline
Exception Handling (1)
John 2012/06/19
Introduction
In programming language mechanisms for exception
handling, the term exception is typically used in a specific
sense to denote a data structure storing information about
an exceptional condition. One mechanism to transfer
control, or raise an exception, is known as a throw. The
exception is said to be thrown. Execution is transferred to a
"catch".
Reference: Wikipedia - Exception Handling http://en.
wikipedia.org/wiki/Exception_handling
How to use
Throw exception:
Catch and try:
if ( num > stopNum )
throw num;
try {
PrintSequence(20);
} catch ( int exNum ){
cout << "Caught an exception With value: " << ExNum
<< endl;
}
Maybe we will write this
● PrintSequence need to return a result.
● Condition for result.
● Define result.
result = PrintSequence(20);
if ( result == NE_NUM)
...
if ( result == NOT_NUM)
...
Why use exception
1. Avoid error never to handle.
2. Avoid our code unreadable.
3. Exception-safe
4. Catching exception with solver who
can solve.
5. Make exception architecture. (More
efficient categories)
6. More information on occur exception.

More Related Content

Viewers also liked

Presentacion Aladi 2013
Presentacion Aladi 2013Presentacion Aladi 2013
Presentacion Aladi 2013
Aladiuy2013
 

Viewers also liked (11)

การประชุมระดมความคิดเห็น Focus Group เทศบาลเมืองหัวหิน 07092015
การประชุมระดมความคิดเห็น Focus Group เทศบาลเมืองหัวหิน 07092015การประชุมระดมความคิดเห็น Focus Group เทศบาลเมืองหัวหิน 07092015
การประชุมระดมความคิดเห็น Focus Group เทศบาลเมืองหัวหิน 07092015
 
Congreso de Factura Electrónica AMETIC, 25 noviembre. Estado de los Puntos Ge...
Congreso de Factura Electrónica AMETIC, 25 noviembre. Estado de los Puntos Ge...Congreso de Factura Electrónica AMETIC, 25 noviembre. Estado de los Puntos Ge...
Congreso de Factura Electrónica AMETIC, 25 noviembre. Estado de los Puntos Ge...
 
Manual de ayuda para procesar pedidos de clientes en EDI
Manual de ayuda para procesar pedidos de clientes en EDIManual de ayuda para procesar pedidos de clientes en EDI
Manual de ayuda para procesar pedidos de clientes en EDI
 
Introduction to Statistics: Descriptive Statistics
Introduction to Statistics: Descriptive StatisticsIntroduction to Statistics: Descriptive Statistics
Introduction to Statistics: Descriptive Statistics
 
Osce
Osce Osce
Osce
 
Gestión de pedidos, preguntas frecuentes
Gestión de pedidos, preguntas frecuentesGestión de pedidos, preguntas frecuentes
Gestión de pedidos, preguntas frecuentes
 
Porting Android
Porting AndroidPorting Android
Porting Android
 
ตัวอย่างข้อตกลงการปฏิบัติราชการ
ตัวอย่างข้อตกลงการปฏิบัติราชการตัวอย่างข้อตกลงการปฏิบัติราชการ
ตัวอย่างข้อตกลงการปฏิบัติราชการ
 
ALADI
ALADIALADI
ALADI
 
Nhà nguyện san alberto magno thiết kế bởi juan pavez aguilar và josé requese...
Nhà nguyện san alberto magno  thiết kế bởi juan pavez aguilar và josé requese...Nhà nguyện san alberto magno  thiết kế bởi juan pavez aguilar và josé requese...
Nhà nguyện san alberto magno thiết kế bởi juan pavez aguilar và josé requese...
 
Presentacion Aladi 2013
Presentacion Aladi 2013Presentacion Aladi 2013
Presentacion Aladi 2013
 

Similar to Java: Exception Handling

Aae oop xp_13
Aae oop xp_13Aae oop xp_13
Aae oop xp_13
Niit Care
 
1.4 core programming [understand error handling]
1.4 core programming [understand error handling]1.4 core programming [understand error handling]
1.4 core programming [understand error handling]
tototo147
 
Exception handling and templates
Exception handling and templatesException handling and templates
Exception handling and templates
farhan amjad
 
Exception handling
Exception handlingException handling
Exception handling
Iblesoft
 
Exception Handling
Exception HandlingException Handling
Exception Handling
backdoor
 

Similar to Java: Exception Handling (20)

Exception handling
Exception handlingException handling
Exception handling
 
Aae oop xp_13
Aae oop xp_13Aae oop xp_13
Aae oop xp_13
 
1.4 core programming [understand error handling]
1.4 core programming [understand error handling]1.4 core programming [understand error handling]
1.4 core programming [understand error handling]
 
JP ASSIGNMENT SERIES PPT.ppt
JP ASSIGNMENT SERIES PPT.pptJP ASSIGNMENT SERIES PPT.ppt
JP ASSIGNMENT SERIES PPT.ppt
 
Exception handling c++
Exception handling c++Exception handling c++
Exception handling c++
 
Exception handling
Exception handlingException handling
Exception handling
 
Exception Handling in object oriented programming using C++
Exception Handling in object oriented programming using C++Exception Handling in object oriented programming using C++
Exception Handling in object oriented programming using C++
 
Exception handling and templates
Exception handling and templatesException handling and templates
Exception handling and templates
 
Exception handling
Exception handlingException handling
Exception handling
 
Exception handling
Exception handlingException handling
Exception handling
 
Exception Handling
Exception HandlingException Handling
Exception Handling
 
12. Exception Handling
12. Exception Handling 12. Exception Handling
12. Exception Handling
 
Class notes(week 8) on exception handling
Class notes(week 8) on exception handlingClass notes(week 8) on exception handling
Class notes(week 8) on exception handling
 
Exception handling
Exception handlingException handling
Exception handling
 
Rethrowing exception- JAVA
Rethrowing exception- JAVARethrowing exception- JAVA
Rethrowing exception- JAVA
 
How to handle exceptions in Java Technology
How to handle exceptions in Java Technology How to handle exceptions in Java Technology
How to handle exceptions in Java Technology
 
Exceptions in java
Exceptions in javaExceptions in java
Exceptions in java
 
Exception Handling
Exception HandlingException Handling
Exception Handling
 
Exception Handling v3
Exception Handling v3Exception Handling v3
Exception Handling v3
 
A exception ekon16
A exception ekon16A exception ekon16
A exception ekon16
 

More from Kan-Han (John) Lu

More from Kan-Han (John) Lu (20)

Dagger for android
Dagger for androidDagger for android
Dagger for android
 
Android develop guideline
Android develop guidelineAndroid develop guideline
Android develop guideline
 
Working process and git branch strategy
Working process and git branch strategyWorking process and git branch strategy
Working process and git branch strategy
 
Deep neural network for youtube recommendations
Deep neural network for youtube recommendationsDeep neural network for youtube recommendations
Deep neural network for youtube recommendations
 
Android testing part i
Android testing part iAndroid testing part i
Android testing part i
 
Cuda project paper
Cuda project paperCuda project paper
Cuda project paper
 
Twitter as a personalizable information service ii
Twitter as a personalizable information service iiTwitter as a personalizable information service ii
Twitter as a personalizable information service ii
 
Multimedia data minig and analytics sentiment analysis using social multimedia
Multimedia data minig and analytics sentiment analysis using social multimediaMultimedia data minig and analytics sentiment analysis using social multimedia
Multimedia data minig and analytics sentiment analysis using social multimedia
 
Android IPC: Binder
Android IPC: BinderAndroid IPC: Binder
Android IPC: Binder
 
ARM: Trusted Zone on Android
ARM: Trusted Zone on AndroidARM: Trusted Zone on Android
ARM: Trusted Zone on Android
 
Android Training - Card Style
Android Training - Card StyleAndroid Training - Card Style
Android Training - Card Style
 
Android Training - View Pager
Android Training - View PagerAndroid Training - View Pager
Android Training - View Pager
 
Android Training - Pull to Refresh
Android Training - Pull to RefreshAndroid Training - Pull to Refresh
Android Training - Pull to Refresh
 
Dynamic Proxy by Java
Dynamic Proxy by JavaDynamic Proxy by Java
Dynamic Proxy by Java
 
Code analyzer: FindBugs and PMD
Code analyzer: FindBugs and PMDCode analyzer: FindBugs and PMD
Code analyzer: FindBugs and PMD
 
Android UI System
Android UI SystemAndroid UI System
Android UI System
 
Android Fragment
Android FragmentAndroid Fragment
Android Fragment
 
Android Training - Content Sharing
Android Training - Content SharingAndroid Training - Content Sharing
Android Training - Content Sharing
 
Android Training - Action Bar
Android Training - Action BarAndroid Training - Action Bar
Android Training - Action Bar
 
Explaination of angular
Explaination of angularExplaination of angular
Explaination of angular
 

Recently uploaded

Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Sérgio Sacani
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOST
Sérgio Sacani
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
gindu3009
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Sérgio Sacani
 
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
anilsa9823
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Sérgio Sacani
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Lokesh Kothari
 
DIFFERENCE IN BACK CROSS AND TEST CROSS
DIFFERENCE IN  BACK CROSS AND TEST CROSSDIFFERENCE IN  BACK CROSS AND TEST CROSS
DIFFERENCE IN BACK CROSS AND TEST CROSS
LeenakshiTyagi
 

Recently uploaded (20)

Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdf
 
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
 
fundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomologyfundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomology
 
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptxUnlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOST
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
 
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
 
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
 
Forensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdfForensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdf
 
Botany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsBotany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questions
 
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 60009654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on Io
 
DIFFERENCE IN BACK CROSS AND TEST CROSS
DIFFERENCE IN  BACK CROSS AND TEST CROSSDIFFERENCE IN  BACK CROSS AND TEST CROSS
DIFFERENCE IN BACK CROSS AND TEST CROSS
 
Chromatin Structure | EUCHROMATIN | HETEROCHROMATIN
Chromatin Structure | EUCHROMATIN | HETEROCHROMATINChromatin Structure | EUCHROMATIN | HETEROCHROMATIN
Chromatin Structure | EUCHROMATIN | HETEROCHROMATIN
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdf
 

Java: Exception Handling

  • 2. Introduction In programming language mechanisms for exception handling, the term exception is typically used in a specific sense to denote a data structure storing information about an exceptional condition. One mechanism to transfer control, or raise an exception, is known as a throw. The exception is said to be thrown. Execution is transferred to a "catch". Reference: Wikipedia - Exception Handling http://en. wikipedia.org/wiki/Exception_handling
  • 3. How to use Throw exception: Catch and try: if ( num > stopNum ) throw num; try { PrintSequence(20); } catch ( int exNum ){ cout << "Caught an exception With value: " << ExNum << endl; }
  • 4. Maybe we will write this ● PrintSequence need to return a result. ● Condition for result. ● Define result. result = PrintSequence(20); if ( result == NE_NUM) ... if ( result == NOT_NUM) ...
  • 5. Why use exception 1. Avoid error never to handle. 2. Avoid our code unreadable. 3. Exception-safe 4. Catching exception with solver who can solve. 5. Make exception architecture. (More efficient categories) 6. More information on occur exception.