Open In App

DecimalStyle equals() method in Java with Example

Last Updated : 26 Aug, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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.

Syntax:

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.

Program:




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


Output:

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

Reference: https://docs.oracle.com/javase/10/docs/api/java/time/format/DecimalStyle.html#equals(java.lang.Object)


Similar Reads

DecimalStyle getDecimalSeparator() method in Java with Example
The getDecimalSeparator() method of java.time.format.DecimalStyle class in Java is used to get the character that is used to represent decimal separator for the Locale of this DecimalStyle. This method returns the character for decimal separator of that Locale. Syntax: public char getDecimalSeparator() Parameter: This method do not accept any param
1 min read
DecimalStyle withNegativeSign() method in Java with Example
The withNegativeSign() method of java.time.format.DecimalStyle class in Java is used to set the character that is used to represent negative sign for the Locale of this DecimalStyle. This method takes the character as the parameter and returns the DecimalStyle instance with the updated negative sign character. Syntax: public DecimalStyle withNegati
1 min read
DecimalStyle hashCode() method in Java with Example
The hashCode() method of java.time.format.DecimalStyle class in Java is used to get the hashCode value of this DecimalStyle. This method returns an integer representing the hashCode value. Syntax: public int hashCode() Parameter: This method do not accept any parameter. Return Value: This method returns an int value which is the hashCode value of t
1 min read
DecimalStyle getPositiveSign() method in Java with Example
The getPositiveSign() method of java.time.format.DecimalStyle class in Java is used to get the character that is used to represent positive sign for the Locale of this DecimalStyle. This method returns the character for positive sign of that Locale. Syntax: public char getPositiveSign() Parameter: This method do not accept any parameter. Return Val
1 min read
DecimalStyle getZeroDigit() method in Java with Example
The getZeroDigit() method of java.time.format.DecimalStyle class in Java is used to get the character that is used to represent zero for the Locale of this DecimalStyle. This method returns the character for zero of that Locale. Syntax: public char getZeroDigit() Parameter: This method do not accept any parameter. Return Value: This method returns
1 min read
DecimalStyle getAvailableLocales() method in Java with Example
The getAvailableLocales() method of java.time.format.DecimalStyle class in Java is used to get the list of all of the available Locales for this DecimalStyle. This method returns a set of the Locales that are available. Syntax: public static Set<Locales> getAvailableLocales() Parameter: This method do not accept any parameter. Return Value: T
2 min read
DecimalStyle ofDefaultLocale() method in Java with Example
The ofDefaultLocale() method of java.time.format.DecimalStyle class in Java is used to get the DecimalStyle instance for the default FORMAT locale. Syntax: public static DecimalStyle ofDefaultLocale() Parameter: This method do not accept any parameter. Return Value: This method returns a DecimalStyle instance for the default FORMAT locale. Exceptio
1 min read
DecimalStyle withPositiveSign() method in Java with Example
The withPositiveSign() method of java.time.format.DecimalStyle class in Java is used to set the character that is used to represent positive sign for the Locale of this DecimalStyle. This method takes the character as the parameter and returns the DecimalStyle instance with the updated negative sign character. Syntax: public void withPositiveSign(c
1 min read
DecimalStyle withZeroDigit() method in Java with Example
The withZeroDigit() method of java.time.format.DecimalStyle class in Java is used to set the character that is used to represent zero for the Locale of this DecimalStyle. This method takes the character as the parameter and returns the DecimalStyle instance with the updated negative sign character. Syntax: public void withZeroDigit(char zeroDigit)
1 min read
DecimalStyle getNegativeSign() method in Java with Example
The getNegativeSign() method of java.time.format.DecimalStyle class in Java is used to get the character that is used to represent negative sign for the Locale of this DecimalStyle. This method returns the character for negative sign of that Locale. Syntax: public char getNegativeSign() Parameter: This method do not accept any parameter. Return Val
1 min read