扫描二维码下载沐宇APP

沐宇

微信扫码使用沐宇小程序

沐宇

Java怎么显示字符的unicode值

扬州沐宇科技
2024-05-06 12:49:48
Java

在Java中,可以使用char数据类型来表示字符,然后通过强制转换为整数类型来获取字符的Unicode值。以下是一个示例代码:

public class Main {
    public static void main(String[] args) {
        char ch = 'A';
        int unicodeValue = (int) ch;
        
        System.out.println("Character: " + ch);
        System.out.println("Unicode value: " + unicodeValue);
    }
}

运行以上代码,将会输出:

Character: A
Unicode value: 65

这样可以很容易地获取字符的Unicode值并进行显示。

扫码添加客服微信