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