⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zerodivideexception.java

📁 JAVA 2入门经典 练习答案
💻 JAVA
字号:
// 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -