CSE 116 Lecture 10: lecture 10 (9.21.16)
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;