DecimalFormatSymbols equals() method in Java with Examples

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


public boolean equals(Object obj)

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

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

Exception: This method do not throw any Exception.






// Java program to demonstrate
// the above method
import java.text.*;
import java.util.*;
public class DecimalFormatSymbolsDemo {
    public static void main(String[] args)
        DecimalFormatSymbols dfs1
            = new DecimalFormatSymbols();
        System.out.println("DecimalFormatSymbols 1: "
                           + dfs1);
        DecimalFormatSymbols dfs2
            = new DecimalFormatSymbols(
                new Locale("JAPANESE"));
        System.out.println("DecimalFormatSymbols 2: "
                           + dfs2);
        DecimalFormatSymbols dfs3
            = (DecimalFormatSymbols)dfs1.clone();
        System.out.println("DecimalFormatSymbols 3: "
                           + dfs3);
        System.out.println("Comparing DFS 1 and DFS 2: "
                           + dfs1.equals(dfs2));
        System.out.println("Comparing DFS 2 and DFS 3: "
                           + dfs2.equals(dfs3));
        System.out.println("Comparing DFS 1 and DFS 3: "
                           + dfs1.equals(dfs3));



DecimalFormatSymbols 1: java.text.DecimalFormatSymbols@1073a
DecimalFormatSymbols 2: java.text.DecimalFormatSymbols@1073a
DecimalFormatSymbols 3: java.text.DecimalFormatSymbols@1073a
Comparing DFS 1 and DFS 2: false
Comparing DFS 2 and DFS 3: false
Comparing DFS 1 and DFS 3: true


Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.

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.