Java Locale setDefault() method

The setDefault() method of Java Locale class is used to set the default locale for this instance of the JVM(Java Virtual Machine). It does not affect the host locale.

Syntax

Parameter

newLocale: It is the new default locale.

Return

NA

Exceptions

SecurityException: This exception will throw if a security manager exists and its checkPermission method doesn't allow the operation.

NullPointerException: This exception will throw if newLocale is null.

Example 1

Output:

Locale1: en_US_WIN

Example 2

Output:

Locale1: en_US
NEW Default locale2: fr_FRANCE_MAC
Locale3: fr_FRANCE_MAC
NEW Default locale4: en_US_WIN