以下是 Java 中获取 ASCII 码值的代码示例:

// 获取字符的 ASCII 码值
char c = 'A';
int ascii = (int) c;
System.out.println('ASCII 码值为:' + ascii);

// 将 ASCII 码值转换为字符
int ascii2 = 65;
char c2 = (char) ascii2;
System.out.println('对应的字符为:' + c2);

输出结果:

ASCII 码值为:65
对应的字符为:A
Java 获取 ASCII 码值代码示例

原文地址: https://www.cveoy.top/t/topic/oLDn 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录