Currency equals(Object) in Java

Currency equals(Object): This method is available in java.util.Currency class of Java.

Syntax:

boolean java.lang.Object.equals(Object obj)

This method takes one argument of type Object (like Currency) as its parameter. This method indicates whether some other object is "equal to" this one.

Parameters: One parameter is required for this method.

obj: the reference object with which to compare.

Returns: true if this object is the same as the obj argument; false otherwise.

Exceptions: NA

Approach

Java

import java.util.Currency;
import java.util.Locale;

public class Currencyequals {
    public static void main(String[] args) {

        Currency currency = Currency.getInstance(Locale.US);
        Currency currency2 = Currency.getInstance(Locale.UK);

        System.out.println(currency.equals(currency2));

    }
}

Output:

false


No comments:

Post a Comment