DecimalStyle equals() method in Java with Example

The equals() method of java.time.format.DecimalStyle class in Java is used to check for equality of this DecimalStyle with the specified DecimalStyle. This method takes a DecimalStyle instance and compares it with this DecimalStyle and returns a boolean value representing the same.


public boolean equals(Object obj)

Parameter: This method accepts a parameter obj which is the DecimalStyle to be checked for equality with this DecimalStyle.

Return Value: This method returns an boolean which tells if this DecimalStyle is equal to the specified Object.

Exception: This method do not throw any Exception.






// Java program to demonstrate
// the above method
import java.time.format.*;
import java.util.*;
public class DecimalStyleDemo {
    public static void main(String[] args)
        DecimalStyle ds1
            = DecimalStyle.STANDARD;
        DecimalStyle ds2
            = DecimalStyle.of(
                new Locale("ENGLISH"));
        DecimalStyle ds3 = null;
        System.out.println("Comparing DS 1 and DS 2: "
                           + ds1.equals(ds2));
        System.out.println("Comparing DS 2 and DS 3: "
                           + ds2.equals(ds3));
        System.out.println("Comparing DS 1 and DS 3: "
                           + ds1.equals(ds3));



Comparing DS 1 and DS 2: true
Comparing DS 2 and DS 3: false
Comparing DS 1 and DS 3: false


Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to 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.