Java Character isValidCodePoint() 方法

6 Nov 2024 | 3 分钟阅读

Character 类的 isValidCodePoint(int codePoint) 方法用于确定给定的(或指定的)字符是否是有效的 Unicode 代码点。

语法

参数

上述方法只需要一个参数

a.) codePoint 是需要测试的字符。

返回值

isValidCodePoint(int codePoint) 方法返回一个布尔值,即,如果给定的(或指定的)字符在 MIN_CODE_POINT 和 MAX_CODE_POINT 之间的范围内,则返回 true。否则,此方法返回 false。

示例 1

输出

The codePoint '12' is a valid codepoint : true
The codePoint '51' is a valid codepoint : true
The codePoint '121' is a valid codepoint : true
The codePoint '160' is a valid codepoint : true

示例 2

输出

The first codePoint '121' is a valid codePoint :true
The second codePoint '128' is a valid codePoint :true
The third codePoint '227' is a valid codePoint  :true
The fourth codePoint '342' is a valid codePoint :true

示例 3

输出

The first codePoint '323' is a valid codePoint :true
The second codePoint '345' is a valid codePoint :true
The third codePoint '564' is a valid codePoint :true
The fourth codePoint '787' is a valid codePoint :true