java实现ascll码转换
时间: 2023-10-19 13:07:22 浏览: 106
Ascll转换器
以下是 Java 实现 ASCII 码转换的示例代码:
```java
public class AsciiConverter {
public static void main(String[] args) {
char ch = 'A';
int ascii = (int) ch;
System.out.println("ASCII code of " + ch + " is: " + ascii);
int asciiCode = 65;
char character = (char) asciiCode;
System.out.println("Character for ASCII code " + asciiCode + " is: " + character);
}
}
```
输出:
```
ASCII code of A is: 65
Character for ASCII code 65 is: A
```
以上代码将字符 `A` 转换为 ASCII 码,并将 ASCII 码 `65` 转换为字符 `A`。你可以根据需要修改代码中的字符或 ASCII 码。
阅读全文