Home » Java programming language

Java Locale getDefault() Method with Example

Locale Class getDefault() method: Here, we are going to learn about the getDefault() method of Locale Class with its syntax and example.
Submitted by Preeti Jain, on March 08, 2020

Locale Class getDefault() method

  • getDefault() method is available in java.util package.
  • getDefault() method is used to return the current value of default locale for this Locale instance of the JVM.
  • getDefault() method is a static method, it is accessible with the class name and if we try to access the method with the class object then we will not get an error.
  • getDefault() method does not throw an exception at the time of returning default locale.

Syntax:

    public static Locale getDefault();

Parameter(s):

  • It does not accept any parameter.

Return value:

The return type of the method is Locale, it returns current value of the default locale.

Example:

// Java program to demonstrate the example 
// of Locale getDefault() method of Locale 

import java.util.*;

public class GetDefaultOfLocale {
    public static void main(String[] args) {
        // By using getDefault() method is
        // to return the default locale 
        Locale lo = Locale.getDefault();

        // Display Locale
        System.out.println("Locale.getDefault(): " + lo);
    }
}

Output

Locale.getDefault(): en_US





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.