GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.tutorialspoint.com — Java.math.MathContext.equals() Method
Selected Reading
Java.math.MathContext.equals() MethodDescriptionThe java.math.MathContext.equals(Object x) compares this MathContext with the specified Object for equality. DeclarationFollowing is the declaration for java.math.MathContext.equals() method. public boolean equals(Object x) Overridesequals in class Object. Parametersx − Object to which this MathContext is to be compared. Return ValueThis method returns true if and only if the specified Object is a MathContext object which has exactly the same settings as this object. ExceptionNA ExampleThe following example shows the usage of math.MathContext.equals() method. package com.tutorialspoint;
import java.math.*;
public class MathContextDemo {
public static void main(String[] args) {
// create 3 MathContext objects
MathContext mc1, mc2, mc3;
// assign context settings to mc1, mc2, mc3
mc1 = new MathContext(2);
mc2 = new MathContext(2, RoundingMode.HALF_UP);
mc3 = new MathContext(2, RoundingMode.HALF_DOWN);
// create 2 boolean objects
Boolean b1, b2;
// compare context settings of mc1 with mc2, mc3
b1 = mc1.equals(mc2);
b2 = mc1.equals(mc3);
String str1 = "Context settings of mc1 and mc2 are equal is " + b1;
String str2 = "Context settings of mc1 and mc3 are equal is " + b2;
// print b1, b2 values
System.out.println( str1 );
System.out.println( str2 );
}
}
Let us compile and run the above program, this will produce the following result − Context settings of mc1 and mc2 are equal is true Context settings of mc1 and mc3 are equal is false java_math_mathcontext.htm
Advertisements
|
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |