Thursday, July 2, 2026
HomeLanguagesJavaLocale.Builder clear() method in Java with Examples

Locale.Builder clear() method in Java with Examples

The clear() method of java.util.Locale.Builder class in Java is used to reset this Locale.Builder. It means that this method will create another instance of Locale.Builder with all the properties reset to their initial state and return it.

Syntax:

public Locale.Builder clear()

Parameter: This method do not accept any parameter.

Return Value: This method returns an Locale.Builder instance which is the reset state of this Locale.Builder set to its initial state.

Exception: This method do not throw any Exception.

Program:




// Java program to demonstrate
// the above method
  
import java.util.*;
import java.util.Locale.*;
  
public class LocaleBuilderDemo {
    public static void main(String[] args)
    {
  
        // Creating a new Locale.Builder
        Locale.Builder localeBuilder
            = new Builder();
  
        // Displaying Locale.Builder
        System.out.println("LocaleBuilder: "
                           + localeBuilder);
  
        // Clearing Locale.Builder
        System.out.println("Clearing the LocaleBuilder");
        localeBuilder = localeBuilder.clear();
  
        // Displaying Locale.Builder
        System.out.println("Cleared LocaleBuilder: "
                           + localeBuilder);
    }
}


Output:

LocaleBuilder: java.util.Locale$Builder@232204a1
Clearing the LocaleBuilder
Cleared LocaleBuilder: java.util.Locale$Builder@232204a1

Reference: https://docs.oracle.com/javase/9/docs/api/java/util/Locale.Builder.html#clear–

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32518 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6900 POSTS0 COMMENTS
Nicole Veronica
12014 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12110 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6966 POSTS0 COMMENTS