Java第二课:汉字的Unicode表位置

来源:互联网 发布:fenng 离职知乎 编辑:程序博客网 时间:2024/06/11 08:10
import java.util.Scanner;public class Unicode{    public static void main(String args[]){        int e=0;char a[];        Scanner q =new Scanner(System.in);        System.out.println("输入要转化的汉字数量");        int w= q.nextInt();        a =new char[w];                                     //初始化数组        for(;e<w;e++){        System.out.println("输入第"+(e+1)+"个汉字");        a[e] = q.next().charAt(0);}                             //输入字符分配给数组        for(e=0;e<w;e++){        System.out.println(a[e]+"的Unicode表十六进制位置为\\u"+Integer.toHexString(a[e]));   //以十六进制输出字符        }    }}

这里写图片描述

原创粉丝点击