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