zerodivideexception.java
来自「Beginning Java 2, SDK 1.4 Edition Exerci」· Java 代码 · 共 27 行
JAVA
27 行
// Chapter 7 Exercise 2
// ZeroDivideException class
public class ZeroDivideException extends Throwable {
private int index = -1; // Index of array element causing error.
// Default Constructor:
public ZeroDivideException(){}
// Standard constructor:
public ZeroDivideException(String s) {
super(s); // Call the base constructor.
}
public ZeroDivideException(int index) {
super("/ by zero"); // Call the base constructor.
this.index = index; // Set the index value.
}
// Get the array index value for the error:
public int getIndex() {
return index; // Return the index value.
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?