Java StringBuffer int codePointAt(int index)方法与示例
StringBuffer类intcodePoint(int索引)
包java.lang.StringBuffer.codePointAt(intindex)中提供了此方法。
此方法用于返回方法中指定索引处的Unicode字符值(UnicodeCodepoint)。
索引范围将从0到length()-1。
此方法不会引发异常。
语法:
int codePointAt(int index){
}参数:
我们只能在StringBuffer的方法(即索引)中传递一个对象。
返回值:
此方法的返回类型为int,这意味着该方法在给定索引处返回字符的Unicode代码点,并且代码点值采用数字格式。
Java程序演示codePointAt(intindex)方法的示例
import java.lang.StringBuffer;
public class StringBufferClass {
public static void main(String[] args) {
StringBuffer sb = new StringBuffer("Java is a programming language : ");
//使用codePointAt(intindex)它将返回Unicode代码点
//指定索引处字符的位置
//后显示结果
System.out.println("The result will be after implementing method codePointAt(2) is :" + sb.codePointAt(2));
sb = new StringBuffer("Java Support OOPS Concept");
//使用codePointAt(intindex)它将返回Unicode代码点
//指定索引处字符的位置
//后显示结果
System.out.println("The result will be after implementing method codePointAt(5) is :" + sb.codePointAt(5));
}
}输出结果
D:\Programs>javac StringBufferClass.java D:\Programs>java StringBufferClass The result will be after implementing method codePointAt(2) is :118 The result will be after implementing method codePointAt(5) is :83
热门推荐
3 祝福语简短的微信
10 幼儿祝福语大全简短贺卡
11 感谢教官文案祝福语简短
12 鼠年同事祝福语简短创意
13 元旦祝福语 简短独特群发
14 妈咪跟我生日祝福语简短
15 给儿子新婚祝福语简短
16 伴娘祝福语长文案简短
17 恭喜高考完祝福语简短
18 生日祝福语送老公简短