Java Character codePointBefore()方法
java.lang.Character.codePointBefore(CharSequence seq, int index) 返回CharSequence的给定索引前面的代码点。如果在(index - 1)的char值在CharSequence是在低代理项范围,(index - 2)不为负,char值(index - 2)在CharSequence的是在高代理项范围,则对应于此代理项对的增补代码点返回。否则,在(index - 1)处的char值返回。
1 语法
public static int codePointBefore(CharSequence seq, int index)
2 参数
seq:该实例的CharSequence
index:下面返回代码点的索引
3 返回值
此方法将返回给定索引之前的Unicode代码点值。
4 示例
package com.yiidian;
/**
* 一点教程网: http://www.yiidian.com
*/
/**
* Java Character codePointBefore()方法
*/
import java.lang.*;
public class CharacterDemo {
public static void main(String[] args) {
// create a CharSequence seq and assign value
CharSequence seq = "Hello";
// create and assign value to index
int index = 4;
// create an int res
int res;
// assign result of codePointBefore on seq at index to res
res = Character.codePointBefore(seq, index);
String str = "Unicode code point is " + res;
// print res value
System.out.println( str );
}
}
输出结果为:
Unicode code point is 108
热门文章
优秀文章