DecimalStyle equals() method in Java with Example

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


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

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.