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

การประชุมระดมความคิดเห็น Focus Group เทศบาลเมืองหัวหิน 07092015
การประชุมระดมความคิดเห็น Focus Group เทศบาลเมืองหัวหิน 07092015การประชุมระดมความคิดเห็น Focus Group เทศบาลเมืองหัวหิน 07092015
การประชุมระดมความคิดเห็น Focus Group เทศบาลเมืองหัวหิน 07092015Thana Chirapiwat
 
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...AMETIC
 
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 EDIEsker Ibérica
 
Introduction to Statistics: Descriptive Statistics
Introduction to Statistics: Descriptive StatisticsIntroduction to Statistics: Descriptive Statistics
Introduction to Statistics: Descriptive StatisticsThana Chirapiwat
 
Gestión de pedidos, preguntas frecuentes
Gestión de pedidos, preguntas frecuentesGestión de pedidos, preguntas frecuentes
Gestión de pedidos, preguntas frecuentesEsker Ibérica
 
ตัวอย่างข้อตกลงการปฏิบัติราชการ
ตัวอย่างข้อตกลงการปฏิบัติราชการตัวอย่างข้อตกลงการปฏิบัติราชการ
ตัวอย่างข้อตกลงการปฏิบัติราชการอลงกรณ์ อารามกูล
 
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...Thi công sơn giá rẻ
 
Presentacion Aladi 2013
Presentacion Aladi 2013Presentacion Aladi 2013
Presentacion Aladi 2013Aladiuy2013
 

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_13Niit 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
 
JP ASSIGNMENT SERIES PPT.ppt
JP ASSIGNMENT SERIES PPT.pptJP ASSIGNMENT SERIES PPT.ppt
JP ASSIGNMENT SERIES PPT.pptJAYAPRIYAR7
 
Exception handling c++
Exception handling c++Exception handling c++
Exception handling c++Jayant Dalvi
 
Exception handling
Exception handlingException handling
Exception handlingzindadili
 
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++Janki Shah
 
Exception handling and templates
Exception handling and templatesException handling and templates
Exception handling and templatesfarhan amjad
 
12. Exception Handling
12. Exception Handling 12. Exception Handling
12. Exception Handling Intro C# Book
 
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 handlingKuntal Bhowmick
 
Exception handling
Exception handlingException handling
Exception handlingIblesoft
 
Rethrowing exception- JAVA
Rethrowing exception- JAVARethrowing exception- JAVA
Rethrowing exception- JAVARajan Shah
 
Exception Handling
Exception HandlingException Handling
Exception Handlingbackdoor
 
Exception Handling v3
Exception Handling v3Exception Handling v3
Exception Handling v3Sunil OS
 
A exception ekon16
A exception ekon16A exception ekon16
A exception ekon16Max Kleiner
 

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

Working process and git branch strategy
Working process and git branch strategyWorking process and git branch strategy
Working process and git branch strategyKan-Han (John) Lu
 
Deep neural network for youtube recommendations
Deep neural network for youtube recommendationsDeep neural network for youtube recommendations
Deep neural network for youtube recommendationsKan-Han (John) Lu
 
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 iiKan-Han (John) Lu
 
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 multimediaKan-Han (John) Lu
 
ARM: Trusted Zone on Android
ARM: Trusted Zone on AndroidARM: Trusted Zone on Android
ARM: Trusted Zone on AndroidKan-Han (John) Lu
 
Android Training - Card Style
Android Training - Card StyleAndroid Training - Card Style
Android Training - Card StyleKan-Han (John) Lu
 
Android Training - View Pager
Android Training - View PagerAndroid Training - View Pager
Android Training - View PagerKan-Han (John) Lu
 
Android Training - Pull to Refresh
Android Training - Pull to RefreshAndroid Training - Pull to Refresh
Android Training - Pull to RefreshKan-Han (John) Lu
 
Code analyzer: FindBugs and PMD
Code analyzer: FindBugs and PMDCode analyzer: FindBugs and PMD
Code analyzer: FindBugs and PMDKan-Han (John) Lu
 
Android Training - Content Sharing
Android Training - Content SharingAndroid Training - Content Sharing
Android Training - Content SharingKan-Han (John) Lu
 
Android Training - Action Bar
Android Training - Action BarAndroid Training - Action Bar
Android Training - Action BarKan-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

Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...RohitNehra6
 
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 GHOSTSérgio Sacani
 
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 asteroidsSérgio Sacani
 
Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)PraveenaKalaiselvan1
 
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 IoSérgio Sacani
 
Bacterial Identification and Classifications
Bacterial Identification and ClassificationsBacterial Identification and Classifications
Bacterial Identification and ClassificationsAreesha Ahmad
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​kaibalyasahoo82800
 
GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)Areesha Ahmad
 
Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...
Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...
Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...Monika Rani
 
Creating and Analyzing Definitive Screening Designs
Creating and Analyzing Definitive Screening DesignsCreating and Analyzing Definitive Screening Designs
Creating and Analyzing Definitive Screening DesignsNurulAfiqah307317
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfmuntazimhurra
 
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRLKochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRLkantirani197
 
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...ssifa0344
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPirithiRaju
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxUmerFayaz5
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )aarthirajkumar25
 
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptxSCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptxRizalinePalanog2
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRDelhi Call girls
 
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.pptxgindu3009
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPirithiRaju
 

Recently uploaded (20)

Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...
 
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
 
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
 
Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)
 
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
 
Bacterial Identification and Classifications
Bacterial Identification and ClassificationsBacterial Identification and Classifications
Bacterial Identification and Classifications
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​
 
GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)
 
Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...
Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...
Vip profile Call Girls In Lonavala 9748763073 For Genuine Sex Service At Just...
 
Creating and Analyzing Definitive Screening Designs
Creating and Analyzing Definitive Screening DesignsCreating and Analyzing Definitive Screening Designs
Creating and Analyzing Definitive Screening Designs
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdf
 
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRLKochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
 
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptx
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptxSCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
 
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
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.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.