java offsetByCodePoints()的用法

offsetByCodePoints

public int offsetByCodePoints(int index , int codePointOffset)
返回此 String 中从给定的 index 处偏移 codePointOffset 个代码点的索引。
如果没有辅助字符的话,这个方法很没有意思
如果有辅助字符的话,就有作用了

String str="hello";
        int n=str.offsetByCodePoints(0,3);
        System.out.println(n);
run:
3

版权声明:本文为weixin_37770552原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。