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.

Syntax:

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.

Program:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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));
    }
}

chevron_right


Output:

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

Reference: https://docs.oracle.com/javase/9/docs/api/java/text/DecimalFormatSymbols.html#equals-java.lang.Object-



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 contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.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.