php    php100   android
當前位置:首頁 » Java.util包 »

Java.util.Locale.getDisplayLanguage(Locale inLocale)方法實例

評論  編輯

描述

The java.util.Locale.getDisplayLanguage(Locale inLocale) method returns a name for the locale's language that is appropriate for display to the user. If possible, the name returned will be localized according to inLocale.

聲明

Following is the declaration for java.util.Locale.getDisplayLanguage() method

public String getDisplayLanguage(Locale inLocale)

參數

  • NA

返回值

This method does not return a value.

異常

  • NullPointerException -- if inLocale is null

實例一

編輯 +分享實例

以下例子將告訴你如何使用 java.util.Locale.getDisplayLanguage() method.

package gitbook.net;

import java.util.*;

public class LocaleDemo {

   public static void main(String[] args) {

      // create a new locale
      Locale locale = new Locale("ENGLISH", "US");

      // print locale
      System.out.println("Locale:" + locale);

      // print language for another locale - result is based on inLocale
      System.out.println("Language:"
              + locale.getDisplayLanguage(new Locale("GERMANY", "GERMAN")));

   }
}

編譯和執行以上程序,將得到以下的結果:

Locale:english_US
Language:english

貢獻/合作者

正在開放中...
 

評論(條)

  • 還冇有評論!