NumberFormat equals() method in Java with Examples Last Updated : 01 Apr, 2019 Comments Improve Suggest changes Like Article Like Report The equals() method is a built-in method of the java.text.NumberFormat accepts an argument which is an object and returns true if this argument object is same as the object, else it returns false. Syntax: public boolean equals(Object arg) Parameters: The function accepts a single mandatory parameter arg which specifies the object which is to be compared with. Return Value: The function returns a boolean value. It returns true if both the objects are same else it returns false. Below is the implementation of the above function: Program 1: Java // Java program to implement // the above function import java.text.NumberFormat; public class Main { public static void main(String[] args) throws Exception { // Get the Currency Instance NumberFormat nF1 = NumberFormat .getCurrencyInstance(); // Get the Currency Instance NumberFormat nF2 = NumberFormat .getCurrencyInstance(); // Check if equal or not if (nF1.equals(nF2)) System.out.println("Yes both are equal"); else System.out.println("Yes both are not equal"); } } Output: Yes both are equal Program 2: Java // Java program to implement // the above function import java.text.NumberFormat; public class Main { public static void main(String[] args) throws Exception { // Get the Currency Instance NumberFormat nF1 = NumberFormat .getCurrencyInstance(); // Get the Instance NumberFormat nF2 = NumberFormat .getInstance(); // Check if equal or not if (nF1.equals(nF2)) System.out.println("Yes both are equal"); else System.out.println("both are not equal"); } } Output: both are not equal Reference: https://docs.oracle.com/javase/10/docs/api/java/text/NumberFormat.html#equals(java.lang.Object) Comment More infoAdvertise with us Next Article NumberFormat equals() method in Java with Examples G gopaldave Follow Improve Article Tags : Java Java-Functions Java-text package Java-NumberFormat Practice Tags : Java Similar Reads Short equals() method in Java with Examples The equals() method of Short class is a built in method in Java which is used to compare the equality given Object with the instance of Short invoking the equals() method. Syntax ShortObject.equals(Object a) Parameters: It takes an Object type object a as input which is to be compared with the insta 2 min read Period equals() method in Java with Examples The equals() method of Period class in Java is used to check if two given periods are equal or not. The comparison is based on the type Period and each of the three years, months and date. To be equal, all of the three year, month and date must be individually equal. Syntax: public boolean equals(Pe 2 min read SortedMap equals() method in Java with Examples In Java, SortedMap is an interface that extends the Map interface and maintains its key-value pairs in ascending order based on the keys' natural ordering or a custom comparator. The equals(Object obj) method of the SortedMap interface is used to compare the SortedMap to the specified object for equ 3 min read ValueRange equals() method in Java with Examples The equals() method of ValueRange class is used to check if this ValueRange is equal to another ValueRange or not where another ValueRange is passed as a parameter to the method. The comparison is based on the four values, minimum, largest minimum, smallest maximum, and maximum. Syntax: public boole 2 min read MonthDay equals() method in Java with Examples The equals() method of MonthDay class in Java checks if this month-day is equal to another month-day. Syntax: public boolean equals(Object obj) Parameter: This method accepts a parameter obj which specifies if this month-day is equal to another month-day. Returns: The function returns true if this i 1 min read Like