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