Java中的 Locale.Builder clear() 方法及示例
Java中Java .util.Locale.Builder类的clear()方法用于重置这个Locale.Builder。这意味着此方法将创建另一个 Locale.Builder 实例,并将所有属性重置为初始状态并将其返回。
句法:
public Locale.Builder clear()
参数:此方法不接受任何参数。
返回值:此方法返回一个 Locale.Builder 实例,该实例是将此 Locale.Builder 设置为其初始状态的重置状态。
异常:此方法不抛出任何异常。
程序:
// 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);
}
}
输出:
LocaleBuilder: java.util.Locale$Builder@232204a1
Clearing the LocaleBuilder
Cleared LocaleBuilder: java.util.Locale$Builder@232204a1
参考: https://docs.oracle.com/javase/9/docs/api/ Java/util/Locale.Builder.html#clear–