Java Reference
In-Depth Information
public static long add(long n1, long n2) {
return n1 + n2;
}
/**
* Returns the result of <code>n1 - n2</code>.
*
* @param n1 The first number
* @param n2 The second number
* @return Returns the result of <code>n1 - n2</code>
*/
public static int subtract(int n1, int n2) {
return n1 - n2;
}
/**
* Returns the result of multiplication of <code>n1</code> and
* <code>n2</code>. It may return incorrect result if the value of
* the multiplication of <code>n1</code> and <code>n2</code>
* exceeds the range of the <code>int</code> data type.
*
* @param n1 The multiplicand
* @param n2 The multiplier
* @return Returns the result of multiplication of
* <code>n1</code> and <code>n2</code>
*/
public static int multiply(int n1, int n2) {
return n1 * n2;
}
/**
* Returns the result of integer division of <code>n1</code> by
* <code>n2</code>.
*
* @param n1 The dividend
* @param n2 The divisor
* @return Returns the result of <code>n1 / n2</code>
* @throws ArithmeticException If <code>n2</code> is zero.
*/
public static int divide(int n1, int n2) throws ArithmeticException {
return n1 / n2;
}
}
 
Search WWH ::




Custom Search