Java Locale equals() method

The equals() method of Java Locale class returns true if this Locale is equal to another object. A Locale is deemed equal to another Locale with identical language, variant, country, extension, script, and unequal to all other objects.

Syntax

Parameter

obj: It is the reference object with which to compare.

Return

It returns the default locale for this instance of Java Virtual Machine

Example 1

Output:

Locale1: company_JAVATPOINT
Locales are equal: false

Example 2

Output:

Locale1: company_JAVATPOINT
Locale2: owner_SONOO
Locale1 and Locale2 are equal: false
Locale2 and Locale3 are equal: true

Example 3

Output:

Locale1: company_JAVATPOINT
Locale2: owner_SONOO
Locale2 and Locale3 are equal: true
Locale1 and Locale4 are equal: true