字符轉對應ASCII碼
// 方法一:將char強制轉換為byte char ch = 'A'; byte byteAscii = (byte) ch; System.out.println(byteAscii); // 方法二:將char直接轉化為int,其值就是字符的ascii int byteAscii1 = (int) ch; System.out.println(byteAscii1);
ASCII碼轉字符
// 直接int強制轉換為char int ascii = 65; char ch1 = (char)ascii; System.out.println(ch1);
