Description Of MathContext: equals(Object x)
The java.math.MathContext.equals(Object x) compares this MathContext with the specified Object for equality.MathContext.equals(Object x) method returns true if and only if the specified Object is a MathContext object which has exactly the same settings as this object.
Code Example Java MathContext
import java.math.MathContext;
import java.math.RoundingMode;
public class BigDecimalExam {
public static void main(String[] args) {
MathContext mc1 = new MathContext(2);
MathContext mc2 = new MathContext(2, RoundingMode.HALF_UP);
MathContext mc3 = new MathContext(2, RoundingMode.HALF_DOWN);
Boolean b1 = mc1.equals(mc2);
Boolean b2 = mc1.equals(mc3);
// print b1, b2 values
System.out.println(b1);
System.out.println(b2);
}
}
ไม่มีความคิดเห็น :
แสดงความคิดเห็น