Locale getScript() in Java

getScript(): This method is available in java.util.Locale class of Java.

Syntax:

String java.util.Locale.getScript()

This method returns the script for this locale, which should either be the empty string or an ISO 15924 4-letter script code. The first letter is uppercase and the rest are lowercase, for example, 'Latn', 'Cyrl'.

Returns: The script code, or the empty string if none is defined.

For Example:

Locale locale = new Locale("latn", "Latin")

locale.getScript() = > It returns an empty String.

Approach

Java

import java.util.Locale;

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

        Locale locale = new Locale("latn""Latin");

        System.out.println("Script is " + locale.getScript());
    }
}

Output:

Script is 

No comments:

Post a Comment