java.lang.StringBuffer.codePointAt()方法实例
java.lang.StringBuffer.codePointAt() 方法返回指定索引处的字符(Unicode代码点)。该指数是指由0 到(Unicode代码单元)范围length()- 1的char值。
声明
以下是java.lang.StringBuffer.codePointAt()方法的声明
public int codePointAt(int index)
参数
-
index -- 这是索引。
返回值
此方法返回字符索引处的代码点值。
异常
-
NA
例子
下面的例子显示java.lang.StringBuffer.codePointAt()方法的使用。
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 at index 5 int retval = buff.codePointAt(5); System.out.println("Character(unicode point) = " + retval); buff = new StringBuffer("amrood admin "); System.out.println("buffer = " + buff); // returns the codepoint at index 6 i.e whitespace character retval = buff.codePointAt(6); System.out.println("Character(unicode point) = " + retval); } }
让我们来编译和运行上面的程序,这将产生以下结果:
buffer = TUTORIALS Character(unicode point) = 73 buffer = amrood admin Character(unicode point) = 32