toString(): This method is available in java.util.Locale class of Java.
Syntax:
String java.util.Locale.toString()
This method returns a string representation of this Locale object, consisting of language, country, variant, script, and extensions.
language + "_" + country + "_" + (variant + "_#" | "#") + script + "_" + extensions
Returns: A string representation of the Locale, for debugging.
For Example:
Locale locale = new Locale("en", "USA", "US")
locale.toString() = > It returns en_USA_US.
Approach
Java
import java.util.Locale;public class LocaletoString {public static void main(String[] args) {Locale locale = new Locale("en", "USA", "US");System.out.println(locale.toString());}}
Output:
en_USA_US
No comments:
Post a Comment