Java StringBuffer codePointBefore()方法
java.lang.StringBuffer.codePointBefore() 法指定索引之前,返回字符(Unicode代码点)。该索引(Unicode代码单元)范围是1到length()的 char值。
1 语法
public int codePointBefore(int index)
2 参数
index : 这是应返回代码点的索引。
3 返回值
此方法返回给定索引之前的Unicode代码点值。
4 示例
package com.yiidian;
/**
* 一点教程网: http://www.yiidian.com
*/
/**
* Java StringBuffer codePointBefore()方法
*/
import java.lang.*;
public class StringBufferDemo {
public static void main(String[] args) {
StringBuffer buff = new StringBuffer("TUTORIALS");
System.out.println("buffer = " + buff);
// returns the codepoint before index 3
int retval = buff.codePointBefore(3);
System.out.println("Character(unicode point) = " + retval);
buff = new StringBuffer("amrood admin ");
System.out.println("buffer = " + buff);
// returns the codepoint before index 6
retval = buff.codePointBefore(6);
System.out.println("Character(unicode point) = " + retval);
}
}
输出结果为:
buffer = TUTORIALS
Character(unicode point) = 84
buffer = amrood admin
Character(unicode point) = 100
热门文章
优秀文章