codepointat java_Java StringBuilder codePointAt()方法

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值