类java.lang.ArithmeticException源码实例Demo

下面列出了怎么用java.lang.ArithmeticException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: pluotsorbet   文件: constructor.java
/**
 * Runs the test using the specified harness.
 *
 * @param harness  the test harness (<code>null</code> not permitted).
 */
public void test(TestHarness harness)
{
    ArithmeticException object1 = new ArithmeticException();
    harness.check(object1 != null);
    harness.check(object1.toString(), "java.lang.ArithmeticException");

    ArithmeticException object2 = new ArithmeticException("nothing happens");
    harness.check(object2 != null);
    harness.check(object2.toString(), "java.lang.ArithmeticException: nothing happens");

    ArithmeticException object3 = new ArithmeticException(null);
    harness.check(object3 != null);
    harness.check(object3.toString(), "java.lang.ArithmeticException");

}
 
源代码2 项目: pluotsorbet   文件: TryCatch.java
/**
 * Runs the test using the specified harness.
 *
 * @param harness  the test harness (<code>null</code> not permitted).
 */
public void test(TestHarness harness)
{
    // flag that is set when exception is caught
    boolean caught = false;
    try {
        throw new ArithmeticException("ArithmeticException");
    }
    catch (ArithmeticException e) {
        // correct exception was caught
        caught = true;
    }
    harness.check(caught);
}
 
源代码3 项目: netcdf-java   文件: SpecialMathFunction.java
public static double atanh(double x) throws ArithmeticException {
  if ((x > 1.0) || (x < -1.0)) {
    throw new ArithmeticException("range exception");
  }
  return 0.5 * Math.log((1.0 + x) / (1.0 - x));
}
 
源代码4 项目: netcdf-java   文件: SpecialMathFunction.java
/**
 * Get the log base 2 of a number
 * 
 * @param x a double value
 * @return The log<sub>2</sub> of x
 * @throws ArithmeticException if (x < 0)
 */
public static double log2(double x) throws ArithmeticException {
  if (x <= 0.0)
    throw new ArithmeticException("range exception");
  return Math.log(x) / log2;
}
 
 类所在包
 类方法
 同包方法