java.lang.Character.codePointBefore(char[ ] a, int index, int start)%uA0返回的字符数组,其中仅可用于数组元素与索引大于或等于start 的给定索引前面的代码点。
如果在char值(index- 1)在char数组是在低代理项范围,(index- 2)不大于启动以内,并在char值(index- 2)在char数组中的高代理范围内,则对应于此代理项对的增补代码点返回。否则,在(index- 1) 的char值返回。
声明
以下是java.lang.Character.codePointBefore()方法的声明
public static int codePointBefore(char[] a, int index, int start)
参数
-
a%uA0- char数组
-
index%uA0- 下面返回代码点的索引
-
start%uA0- 第一个数组元素的字符数组于的索引
返回值
此方法将返回给定索引之前的Unicode代码点值。
异常
-
NullPointerException%uA0- 如果%uA0a 为 null.
-
IndexOutOfBoundsException%uA0- 如果索引参数不大于start参数或大于字符数组的长度,或如果开始参数为负或不大于字符数组的长度。
例子
下面的例子显示lang.Character.codePointBefore()方法的使用。
package com.yiibai import java.lang.* public class CharacterDemo { public static void main(String[] args) { // create a char array c char[] c = new char[] { &aposA&apos, &aposb&apos, &aposC&apos, &aposd&apos} // create and assign value to index, start int index = 3, start = 1 // create an int res int res // assign result of codePointBefore on c at index to res using start res = Character.codePointBefore(c, index, start) String str = "Unicode code point is " + res // print res value System.out.println( str ) } }
让我们来编译和运行上面的程序,这将产生以下结果:
Unicode code point is 67