將 Unicode 儲存在 Java 中的字元變數中


若要將 Unicode 儲存在字元變數中,只需建立一個字元變數。

char c;

現在分配 Unicode。

char c = '\u00AB';

以下是一個完整的示例,顯示 Unicode 儲存在 char 變數中並顯示時的內容:。

示例

 即時演示

public class Demo {
   public static void main(String []args) {
      int a = 79;
      System.out.println(a);
      char b = (char) a;
      System.out.println(b);
      char c = '\u00AB';
      System.out.println(c);
   }
}

輸出

79
O
«

更新於:2020 年 6 月 26 日

1K+ 瀏覽

開啟您的職業生涯

完成課程獲得認證

開始吧
Advertisement
© . All rights reserved.