equals(): This method is available in java.util.Locale class of Java.
Syntax:
boolean java.util.Locale.equals(Object obj)
This method takes one argument of type Object as its parameter. This method returns true if this Locale is equal to another object.
Parameters: One parameter is required for this method.
obj: the reference object with which to compare.
Returns: true if this Locale is equal to the specified object.
For Example:
Locale locale1 = new Locale("en", "IN")
Locale locale2 = new Locale("en", "IN")
locale1.equals(locale2) = > It returns true.
Approach
Java
import java.util.Locale;public class Localeequals {public static void main(String[] args) {Locale locale1 = new Locale("en", "IN");Locale locale2 = new Locale("en", "IN");System.out.println(locale1.equals(locale2));}}
Output:
true
No comments:
Post a Comment