Java Character reverseBytes() 方法

2024 年 11 月 6 日 | 阅读 2 分钟

Character 类的 reverseBytes(char ch) 方法会返回给定值按特定顺序反转字节后获得的值。

语法

参数

ch:需要测试的字符。

返回值

reverseBytes(char ch) 方法返回的是通过反转给定 char 值中的字节而获得的值。

示例 1

输出

Enter the first input:Helllo
The reversing of the character 'H' will provide the result as:18432
The reversing of the character 'e' will provide the result as:25856
The reversing of the character 'l' will provide the result as:27648
The reversing of the character 'l' will provide the result as:27648
The reversing of the character 'l' will provide the result as:27648
The reversing of the character 'o' will provide the result as:28416
Enter the second input:World
The reversing of the character 'W' will provide the result as:22272
The reversing of the character 'o' will provide the result as:28416
The reversing of the character 'r' will provide the result as:29184
The reversing of the character 'l' will provide the result as:27648
The reversing of the character 'd' will provide the result as:25600

示例 2

输出

The reversing of bytes for the first character is given as: ]
The reversing of bytes for the second character is given as: M