whereami.java

来自「Java经典例程 从外国一大学计算机教授出版物下载的代码 经典」· Java 代码 · 共 37 行

JAVA
37
字号
import java.util.*;

class WhereAmI {

  /*  The program for finding Where Am I?   by J M Bishop Dec 1997
   *  -----------------------------------
   *                                        updated July 2000
   *  Illustrates the use of classes in Java packages
   *  and the facility of changing locales.
   */

  public static void main (String [ ] args) {
    new WhereAmI ();
  }

  WhereAmI () {
    Locale here = Locale.getDefault();

    System.out.println("My Locale is " + here);
    System.out.println("Country:  " + here.getCountry());
    System.out.println("Language: " + here.getLanguage());
    System.out.println("Country:  " + here.getDisplayCountry());
    System.out.println("Language: " + here.getDisplayLanguage());
    System.out.println();


    Locale there = new Locale("GERMAN","GERMANY");
    there.setDefault(Locale.GERMANY);
    System.out.println("New Locale is " + there);
    System.out.println("Country:  " + there.getCountry());
    System.out.println("Language: " + there.getLanguage());
    System.out.println("Country:  " + there.getDisplayCountry());
    System.out.println("Language: " + there.getDisplayLanguage());

  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?