java.lang.StringBuffer.codePointBefore()方法实例
java.lang.StringBuffer.codePointBefore() 法指定索引之前,返回字符(Unicode代码点)。该索引(Unicode代码单元)范围是1到length()的 char值。
声明
以下是java.lang.StringBuffer.codePointBefore()方法的声明
public int codePointBefore(int index)
参数
-
index -- 这是应返回代码点的索引。
返回值
此方法返回给定索引之前的Unicode代码点值。
异常
-
NA
例子
下面的例子显示java.lang.StringBuffer.codePointBefore()方法的使用。
package com.yiibai; 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