






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
In the course of the Introduction to Jave Programming, we study the basic syntax and the basic program in java. In these lecture slides the key points are:Exceptions, Throw and Catch, Runtime Errors, Programming, Two Major Parts, Normal Execution, Treat Unusual Events, Encountered Runtime Errors, Coding Experiences, Runtime Error Happens
Typology: Slides
1 / 11
This page cannot be seen from the preview
Don't miss anything!
You have no doubt encountered runtime errors during your coding experiences Normally when a runtime error happens, the angry red text appears and stops your program Your program can actually continue running if you use try and catch block
A try block simply has the word try before it If a runtime error (or a specific error) happens inside this try block, you will be thrown to the catch block
You can define your own exceptions if you do not want to use an existing one: The above is using throw with Exception constructor (takes one String argument) (See: ManualException.java)
Just as Object is the parent to all classes, Exception is the parent to all exceptions This means if you write: catch(Exception e) then it will catch all runtime exceptions If the exception in your catch does not match the exception that happened in try, then your code will have a normal runtime error
You can use multiple catch statements for a single try block Only the first catch statement which satisfies the exception will run (If you put catch(Exception e) as first catch, then you will never get to later ones) (See: MultiCatch.java) Docsity.com