Java StringBuilder codePointAt()方法
java.lang.StringBuilder.codePointAt() 方法返回指定索引处的字符(Unicode代码点)。该索引是指从0 (Unicode代码单元)到length()- 1范围的char值。
1 语法
public int codePointAt(int index)
2 参数
index : 此为索引的char值。
3 返回值
此方法返回字符索引处的代码点值。
4 示例
package com.yiidian;
/**
* 一点教程网: http://www.yiidian.com
*/
/**
* Java StringBuilder codePointAt()方法
*/
import java.lang.*;
public class StringBuilderDemo {
public static void main(String[] args) {
StringBuilder str = new StringBuilder("programming");
System.out.println("string = " + str);
// returns the codepoint at index 5
int retval = str.codePointAt(5);
System.out.println("Character(unicode point) = " + retval);
str = new StringBuilder("amrood admin ");
System.out.println("string = " + str);
// returns the codepoint at index 6 i.e whitespace character
retval = str.codePointAt(6);
System.out.println("Character(unicode point) = " + retval);
}
}
输出结果为:
Enums can never be cloned...
CellPhone List:
Samsung costs 400 dollars
Nokia costs 250 dollars
热门文章
优秀文章