Java中java.util.Locale.Builder類的clearExtensions()方法用於將Locale.Builder的擴展名重置為初始狀態和空狀態。語言,腳本,變體和區域的所有其他值通過此方法保持不變。
用法:
public Locale.Builder clearExtensions()
參數:此方法不接受任何參數。
返回類型:此方法返回一個Locale.Builder實例,其擴展名重置為其初始狀態和空狀態。
異常:此方法不會引發任何異常。
程序1:
// 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 the extensions
// of Locale.Builder
System.out.println("Clearing the"
+ " extensions.");
localeBuilder
= localeBuilder.clearExtensions();
// Displaying Locale.Builder
System.out.println("Updated LocaleBuilder:"
+ localeBuilder);
}
}
輸出:
LocaleBuilder:java.util.Locale$Builder@232204a1 Clearing the extensions. Updated LocaleBuilder:java.util.Locale$Builder@232204a1
程序2:
// 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);
localeBuilder
= localeBuilder
.setExtension('u',
"ca-japanese");
// Displaying Locale.Builder
System.out.println("Extension set "
+ "of LocaleBuilder:"
+ localeBuilder);
// clearing the extensions
// of Locale.Builder
System.out.println("Clearing the"
+ " extensions.");
localeBuilder
= localeBuilder.clearExtensions();
// Displaying Locale.Builder
System.out.println("Updated LocaleBuilder:"
+ localeBuilder);
}
}
輸出:
LocaleBuilder:java.util.Locale$Builder@232204a1 Extension set of LocaleBuilder:java.util.Locale$Builder@232204a1 Clearing the extensions. Updated LocaleBuilder:java.util.Locale$Builder@232204a1
參考: https://docs.oracle.com/javase/9/docs/api/java/util/Locale.Builder.html#clearExtensions-
相關用法
- Java Java.util.Collections.rotate()用法及代碼示例
- Java Java lang.Long.highestOneBit()用法及代碼示例
- Java Java lang.Long.byteValue()用法及代碼示例
- Java Java.util.Collections.disjoint()用法及代碼示例
- Java Java lang.Long.numberOfLeadingZeros()用法及代碼示例
- Java Java lang.Long.reverse()用法及代碼示例
- Java Java lang.Long.lowestOneBit()用法及代碼示例
- Java Java lang.Long.numberOfTrailingZeros()用法及代碼示例
- Java Java lang.Long.builtcount()用法及代碼示例
- Java Clock withZone()用法及代碼示例
- Java Clock tickMinutes()用法及代碼示例
- Java Map put()用法及代碼示例
- Java Set contains()用法及代碼示例
注:本文由純淨天空篩選整理自Code_r大神的英文原創作品 Locale.Builder clearExtensions() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。