The java.math.MathContext.equals() is an in-built function in Java which checks for equality between this MathContext object with the object passed as parameter to the function. The function returns true if the context settings of both the aforementioned objects are same.
public boolean equals(Object obj)
Parameters : The function accepts an object obj as a mandatory parameter with which the MathContext is checked for equality.
Return Value: This method returns true if and only if the specified Object is a MathContext object with same context settings as this object.
Input : m1 = new MathContext(2, RoundingMode.UP), m2 = new MathContext(2, RoundingMode.HALF_UP) Output : false Input : m1 = new MathContext(2), m2 = new MathContext(2, RoundingMode.HALF_UP) Output : true
Below programs will illustrate the use of java.math.MathContext.equals() :
Program 1 :
Program 2 :
- MathContext getPrecision() Method in Java
- MathContext toString() Method in Java
- RuleBasedCollator equals() method in Java with Example
- LinkedBlockingDeque equals() method in Java with Example
- Map equals() method in Java with Examples
- DecimalFormat equals() method in Java
- ParsePosition equals() method in Java with Example
- HashSet equals() method in Java with Example
- Vector equals() Method in Java
- CopyOnWriteArraySet equals() method in Java
- LongBuffer equals() method in Java
- Calendar.equals() method in Java
- Stack equals() method in Java with Example
- IntBuffer equals() method in Java
- Difference between == and .equals() method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.