CSE 116 Lecture 10: lecture 10 (9.21.16)

32 views5 pages

Document Summary

Parameters and fields only used as necessary (which is often) instance variables should be private. Act out what happens to instance within the method. Keep strict focus to eliminate distractors and other issues feel free to add comments to explain what happens from the o(cid:271)je(cid:272)t"s perspective protected int[][] magic; public void setentry (int row, int col, int newv) { magic[row][col] = newv; How to handle an error: alert application to error and stop execution, execute code handling error and crash if none exists. Exception: situation or case not conforming to the general rule the proper way to signal an error (in object-oriented code) Exception is a class defined by java. Java predefines many subclasses of exception there are many exception subclasses, all are runtimeexceptions (unfixable errors) i. e. indexoutofboundsexception, nullpointerexception, stackoverflowexcept. Error handling based upon exception classes: classes can include fields, methods, and constructors, must create instances to have objects to use. Throwing an exception public class bankaccount{ private float balance;

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents