日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

java 方法 示例_Java语言环境getDisplayCountry()方法与示例

發布時間:2025/3/11 java 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java 方法 示例_Java语言环境getDisplayCountry()方法与示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

java 方法 示例

區域設置類getDisplayCountry()方法 (Locale Class getDisplayCountry() method)

Syntax:

句法:

public final String getDisplayCountry();public String getDisplayCountry(Locale lo);
  • getDisplayCountry() method is available in java.util package.

    getDisplayCountry()方法在java.util包中可用。

  • getDisplayCountry() method is used to display the country name for this Locale.

    getDisplayCountry()方法用于顯示此語言環境的國家/地區名稱。

  • getDisplayCountry(Locale lo) method is used to display the country name for the locale and the displayed name will be localized as per based on the given parameter (lo) when possible.

    getDisplayCountry(Locale lo)方法用于顯示語言環境的國家/地區名稱,并且在可能的情況下,將根據給定的參數(lo)根據顯示的名稱進行本地化。

  • These methods may throw an exception at the time of displaying the name of the country.

    這些方法在顯示國家/地區名稱時可能會引發異常。

    NullPointerException: This exception may throw when the given parameter is null exists.

    NullPointerException :當給定參數為null時,可能引發此異常。

  • These are non-static methods and it is accessible with the class object and if we try to access these methods with the class name then also we will get an error.

    這些是非靜態方法,可通過類對象訪問,如果嘗試使用類名訪問這些方法,則也會收到錯誤消息。

Parameter(s):

參數:

  • In the first case, getDisplayCountry() – It does not accept any parameter.

    在第一種情況下, getDisplayCountry() –它不接受任何參數。

  • In the second case, getDisplayCountry(Locale lo)

    在第二種情況下, getDisplayCountry(Locale lo)

    Locale lo – represents the locale whose localized behavior depends on the displayed name.

    語言環境lo –表示語言環境的本地化行為取決于顯示的名稱。

Return value:

返回值:

In both the cases, the return type of the method is String,

在這兩種情況下,方法的返回類型均為String 。

  • In the first case, it displays the country name for this locale.

    在第一種情況下,它顯示此語言環境的國家/地區名稱。

  • In the second case, it displays the country name for the locale based on the given parameter.

    在第二種情況下,它將根據給定的參數顯示語言環境的國家/地區名稱。

Example:

例:

// Java program to demonstrate the example // of getDisplayCountry() method of Localeimport java.util.*;public class GetDisplayCountryOfLocale {public static void main(String[] args) {// Instantiates LocaleLocale lo1 = Locale.getDefault();Locale lo2 = new Locale("JAPANESE", "JAPAN");// Display LocaleSystem.out.println("lo1: " + lo1);System.out.println("lo2: " + lo2);// By using getDisplayCountry() method is// to return the country name this localeString co1 = lo1.getDisplayCountry();System.out.println("lo1.getDisplayCountry(): " + co1);// By using getDisplayCountry(locale) method is// to return the country name this locale will// be localized by the given localeString co2 = lo1.getDisplayCountry(lo2);System.out.println("lo1.getDisplayCountry(lo2): " + co2);} }

Output

輸出量

lo1: en_US lo2: japanese_JAPAN lo1.getDisplayCountry(): United States lo1.getDisplayCountry(lo2): United States

翻譯自: https://www.includehelp.com/java/locale-getdisplaycountry-method-with-example.aspx

java 方法 示例

總結

以上是生活随笔為你收集整理的java 方法 示例_Java语言环境getDisplayCountry()方法与示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。