Java Character charValue() 方法

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

character 类的 charValue() 方法用于确定对象的 char 值。此方法用于将 Character 对象转换为其原始数据类型 char。

语法

参数

不适用

返回值

character 类的 charValue() 方法返回对象的原始 char 值。

示例 1

输出

The character value of char1 is = A
The character value of char2 is = B

示例 2

输出

The primitive char value of a is: 1
The primitive char value of b is: 2
The primitive char value of c is: 3
The primitive char value of d is: 4
The primitive char value of e is: 5

示例 3

输出

Primitive char value is z
Primitive char value is e
Primitive char value is r
Primitive char value is o
z   e    r    o