java.lang.Character.codePointBefore(char[ ] a, int index)%uA0返回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)
参数
-
a%uA0- 字符数组
-
index%uA0- 下面返回代码点的索引
返回值
此方法将返回给定索引之前Unicode代码点值。
异常
-
NullPointerException%uA0- 如果%uA0a 为%uA0null.
-
IndexOutOfBoundsException%uA0- 如果索引参数大于字符数组的长度或小于1。
例子
下面的例子显示lang.Character.codePointBefore()方法的使用。
package com.yiibai import java.lang.* public class CharacterDemo { public static void main(String[] args) { // create a char array c and assign values char[] c = new char[] { &aposa&apos, &aposb&apos, &aposc&apos, &aposd&apos, &apose&apos } // create and assign value to index int index = 2 // create an int res int res // assign result of codePointBefore on array c at index to res res = Character.codePointBefore(c, index) String str = "Unicode code point is " + res // print res value System.out.println( str ) } }
让我们来编译和运行上面的程序,这将产生以下结果:
Unicode code point is 98