COMPSCI 61B Lecture Notes - Lecture 14: Stack Trace, Call Stack, Pseudocode

35 views7 pages

Document Summary

When something goes wrong, break the ow of control. We can also throw our own exceptions using the throw keyword. Can provide more informative message to a user. Can provide more information to some sort of error handling code. Used to handle errors, e. g. you try to use 383,124 gigabytes of memory. You try to cast an object as a dog, but dynamic type is not dog. You try to call a method using a reference variable that is equal to null. You try to access index -1 in an array. Exceptions are instances of classes like most everything else in java. Can catch" exceptions instead, preventing program from crashing. Use the keywords try and catch to break normal ow. Allows you to keep error handling code separate from real" code. When an exception is thrown, it descends the call stack.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents