Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

DecimalStyle equals() method in Java with Example

  • Last Updated : 26 Aug, 2019

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:

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

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)

My Personal Notes arrow_drop_up
Recommended Articles
Page :