Java.lang.StringBuffer.codePointAt() 方法
描述
java.lang.StringBuffer.codePointAt() 方法返回指定 index 处的字符(Unicode 代码点)。索引指的是 char 值(Unicode 代码单元)和 范围从 0 到 length() - 1。
声明
以下是 java.lang.StringBuffer.codePointAt() 方法的声明。
public int codePointAt(int index)
参数
index − 这是 char 值的索引。
返回值
此方法返回索引处字符的代码点值。
异常
NA
示例
下面的例子展示了 java.lang.StringBuffer.codePointAt() 方法的使用。
package com.tutorialspoint;
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

