StringBuilder类codePointCount()方法 (StringBuilder Class codePointCount() method)

  • codePointCount() method is available in java.lang package.

    codePointCount()方法在java.lang包中可用。

  • codePointCount() method is used to count the number of Unicode code points lies in the given range beg_idx to end_idx.

    codePointCount()方法用于计算从beg_idx到end_idx的给定范围内的Unicode代码点数。

  • codePointCount() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    codePointCount()方法是一种非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • codePointCount() method may throw an exception at the time of assigning index.

    分配索引时, codePointCount()方法可能会引发异常。

    IndexOutOfBoundsException - This exception may throw when the beg_idx < 0 or end_idx is not less than the length of this array sequence or the other condition is beg_idx > end_idx.

    IndexOutOfBoundsException-当beg_idx <0或end_idx不小于此数组序列的长度或其他条件为beg_idx> end_idx时,可能引发此异常。

Syntax:

句法:

    public int codePointCount(int beg_idx , int end_idx);

Parameter(s):

参数:

  • int beg_idx – represents the starting index of Unicode code point to start.

    int beg_idx –表示要开始的Unicode代码点的起始索引。

  • int end_idx – represents the ending index of Unicode code point to ends.

    int end_idx –表示Unicode代码指向结尾的结尾索引。

Return value:

返回值:

The return type of this method is int, it returns the counts of the number of Unicode code point of the given range.

此方法的返回类型为int ,它返回给定范围的Unicode代码点的数量的计数。

Example:

例:

// Java program to demonstrate the example
// of int codePointCount(int beg_idx , int end_idx)
// method of StringBuilder
public class CodePointCount {public static void main(String[] args) {// Creating an StringBuilder object
StringBuilder st_b = new StringBuilder("Java World");
System.out.println("st_b = " + st_b);
// By using codePointCount(4,8) method is to count the
// number of codepoint lies in a range from index 4
// to index 8
int cp = st_b.codePointCount(4, 8);
// Display all the codepoints from index 4 to index 8
System.out.println("st_b.codePointCount(4,8) = " + cp);
}
}

Output

输出量

st_b = Java World
st_b.codePointCount(4,8) = 4

翻译自: https://www.includehelp.com/java/stringbuilder-codepointcount-method-with-example.aspx

Java StringBuilder codePointCount()方法与示例相关推荐

  1. Java IOUtils.copy方法代码示例(亲测)

    本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...

  2. setlength java_Java StringBuilder setLength()方法与示例

    StringBuilder类setLength()方法setLength()方法在java.lang包中可用. setLength()方法用于在将字符序列替换为新字符序列时设置字符序列的长度,因此该序 ...

  3. java codepointbefore_Java StringBuilder codePointBefore()方法与示例

    StringBuilder类codePointBefore()方法codePointBefore()方法在java.lang包中可用. codePointBefore()方法用于表示给定索引和数组索引 ...

  4. java user directory,Java ProcessBuilder directory()方法与示例

    语法:public File directory (); public ProcessBuilder directory (File dir); ProcessBuilder类directory()方 ...

  5. Java序列化魔术方法及其示例使用

    在上一篇文章中, 您需要了解有关Java序列化的所有知识 ,我们讨论了如何通过实现Java序列化来启用类的可序列化性. Serializable接口. 如果我们的类未实现Serializable接口, ...

  6. catalog java,Java Connection getCatalog()方法与示例

    通常,目录是一个目录,其中包含有关数据集,文件或数据库的信息.而数据库目录中包含所有数据库,基本表,视图(虚拟表),同义词,值范围,索引,用户和用户组的列表. Connection接口的getCata ...

  7. filepermission java,Java FilePermission getActions()方法与示例

    FilePermission类getActions()方法getActions()方法在java.io包中可用. getActions()方法用于检查此FilePermission和给定对象在路径名和 ...

  8. java方法参数Bundle,Java ResourceBundle keySet()方法及示例

    ResourceBundle类keySet()方法keySet()方法在java.util包中可用. keySet()方法用于从此ResourceBundle及其超级捆绑包中获取所有现有键,以在Set ...

  9. java exec waitfor,Java Process waitFor()方法与示例

    流程类waitFor()方法在java.lang包中提供了waitFor()方法. waitFor()方法用于使当前正在运行的线程在需要时等待,直到由该Process对象表示的进程完成其终止为止. 当 ...

最新文章

  1. Banknote Dataset(钞票数据集)介绍
  2. 关于python的一些好的书籍推荐-荐书||关于Python的一些书籍推荐
  3. (格式化字符串漏洞).fini.array劫持,使程序流程循环进行
  4. 卷积神经网络 卷积的概念
  5. MFC实现Windows锁屏
  6. python3输入输出_Python3 输入和输出
  7. 实例45:python
  8. php7 关联nginx,nginx+php7配合开发
  9. 使用GUID作为数据库主键与INT作为主键的性能测试
  10. java并发:原子类之AtomicLong
  11. Javascript--闭包引起的IE内存泄露(转载)
  12. 使用Axis,在webservice的服务器端如何取到客户端的IP地址
  13. levy过程、扩散过程、随机过程带跳
  14. jquery系列教程4-事件操作全解
  15. 实际打印页码偏上_4个Excel打印小技巧,想怎么打就怎么打?
  16. rust-vmm 学习
  17. Unity3D游戏开发之换装系统的实现
  18. 查看 SQL2005 Reporting services文件夹报表权限
  19. Angular:升级Angular 13到Angular 14
  20. 3d游戏开发实训一周总结 3

热门文章

  1. mysql 表设计 date_mysql 表 Date类型
  2. jwt重放攻击_4个点搞懂JWT、JWS、JWE
  3. java undo_用JAVA实现Undo、Redo,Copy、Paste、Cut_java
  4. 福州大学计算机专业考研,2015年福州大学计算机考研经验贴
  5. django mysql 表单_Python Django 表单提交数据到mysql并展示
  6. 撸个微信小程序的省市区选择器
  7. 20080408 - VS2003 中 Jscript 文件中文乱码问题
  8. HTTP Developer's Handbook Part V: Security 读书笔记
  9. Myeclipse debug时出现跳行问题的解决
  10. 20170117小测