Java StringBuilder codePointCount()方法与示例

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/379742.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

FreeRTOS时间管理

在使用FreeRTOS的过程中&#xff0c;我们通常会在一个任务函数中使用延时函数对这个任务延时&#xff0c;当执行延时函数的时候就会进行任务切换&#xff0c;并且此任务就会进入阻塞太&#xff0c;直到延时完成&#xff0c;任务重新进入就绪态。延时函数舒属于FreeRTOS的时间管…

set和multiset集合容器

三、①set集合容器 简介&#xff1a;set集合的目的就是为了快速检索。set集合容器实现了红黑树的平衡二叉检索树的数据结构。set集合里面不允许有重复的元素出现&#xff1b;使用set容器前&#xff0c;需要在程序的头文件中声明 #include < set >。 函数方法总结&#…

javascript获取select的值全解

获取显示的汉字 document.getElementById("bigclass").options[window.document.getElementById("bigclass").selectedIndex].text 获取数据库中的id window.document.getElementById("bigclass").value 获取select组分配的索引id window.docume…

Java File类void deleteOnExit()方法(带示例)

文件类void deleteOnExit() (File Class void deleteOnExit()) This method is available in package java.io.File.deleteOnExit(). 软件包java.io.File.deleteOnExit()中提供了此方法。 This method is used to delete the file or directory when the virtual machine termi…

FreeRTOS队列

在实际应用中&#xff0c;我们会遇到一个任务或者中断服务需要和另一个任务进行消息传递&#xff0c;FreeRTOS提供了队列的机制来完成任务与任务、任务与中断之间的消息传递。 0x01 队列简介 队列是为了任务与任务、任务与中断之间的通信而准备的&#xff0c;可以在任务与任务…

括号配对问题(C)

描述 现在&#xff0c;有一行括号序列&#xff0c;请你检查这行括号是否配对。 输入 第一行输入一个数N&#xff08;0<N<100&#xff09;,表示有N组测试数据。后面的N行输入多组输入数据&#xff0c;每组输入数据都是一个字符串S(S的长度小于10000&#xff0c;且S不是空串…

剧情介绍:“阿甘正传”

阿甘是个智商只有75的低能儿。在学校里为了躲避别的孩子的欺侮&#xff0c;听从一个朋友珍妮的话而开始“跑”。他跑着躲避别人的捉弄。在中学时&#xff0c;他为了躲避别人而跑进了一所学校的橄榄球场&#xff0c;就这样跑进了大学。阿甘被破格录取&#xff0c;并成了橄榄球巨…

java 方法 示例_Java集合syncedList()方法与示例

java 方法 示例集合类syncList()方法 (Collections Class synchronizedList() method) synchronizedList() method is available in java.util package. syncList()方法在java.util包中可用。 synchronizedList() method is used to return the synchronized view of the given…

FreeRTOS信号量---二值信号量

信号量可以用来进行资源管理和任务同步&#xff0c;FreeRTOS中信号量又分为二值信号量、计算型信号量、互斥信号量和递归互斥信号量。 0x01 二值信号量 二值信号量其实就是一个只有一个队列项的队列&#xff0c;这个特殊的队列要么是满的&#xff0c;要么是空的&#xff0c;任…

Linux 上 rpm包管理工具的基本使用

查询是否安装某个包&#xff1a;rpm -q 包名查询所有已安装的包&#xff1a;rpm -q a查询未安装包的文件信息&#xff1a;rpm -qilp 未安装的包安装包&#xff1a;rpm -i 包测试安装包&#xff1a;rpm -i test 包删除包&#xff1a;rpm -e 包名测试删除包&#xff1a;rpm -e te…

ios 内存使用陷阱

在iphone开发过程中&#xff0c;代码中的内存泄露我们很容易用内存检测工具leaks 检测出来&#xff0c;并一一改之&#xff0c;但有些是因为ios 的缺陷和用法上的错误&#xff0c;leaks 检测工具并不能检测出来&#xff0c;你只会看到大量的内存被使用&#xff0c;最后收到didR…

FreeRTOS软件定时器

软件定时器允许设置一段时间&#xff0c;当设置的时间达到后就执行指定的功能函数&#xff0c;被软件定时器调用的功能函数叫做定时器的回调函数。软件定时器的回调函数是在定时器服务任务中执行的&#xff0c;所以一定不能在回调函数中调用任何阻塞任务的API函数&#xff0c;比…

Java类class isAssignableFrom()方法及示例

类class isAssignableFrom()方法 (Class class isAssignableFrom() method) isAssignableFrom() method is available in java.lang package. isAssignableFrom()方法在java.lang包中可用。 isAssignableFrom() method is used to check whether the class or an interface den…

关于 列表实例

wss3.0工具中有个列表实例项目。此项目的作用是在自定义网站或自定义字段时使用默认值。也就是定义其默认的数据。 格式详见微软msdn&#xff1a;http://msdn.microsoft.com/zh-cn/library/ms478860.aspx转载于:https://www.cnblogs.com/heavencloud/archive/2009/03/20/141793…

WP7之Application Bar控件

Microsoft.Phone.Shell命名空间中定义了ApplicationBar及其相关类&#xff08;ApplicationBarIconButton和ApplicationBarMenuItem&#xff09;&#xff0c;这些类派生自Object,并完全独立于常规Silverlight编程中的DependencyObject,UIElement和FrameworkElement类层次结构。A…

TomCat使用以及端口号被占用的处理方法

一.HTTP协议 什么是HTTP协议 HTTP协议&#xff08;HyperText Transfer Protocol&#xff0c;超文本传输协议&#xff09;是因特网上应用最为广泛的一种网络传输协议&#xff0c;所有的WWW文件都必须遵守这个标准。 HTTP请求 HTTP响应 2.如何处理端口被占用 方法一&#xff…

FreeRTOS事件标志组

使用信号量来同步的话&#xff0c;任务只能与单个事务或任务进行同步&#xff0c;有时候某个任务可能会需要与多个事件或任务进行同步&#xff0c;此时信号量就无能为力了&#xff0c;FreeRTOS为此提供了一个可选的解决方法&#xff0c;那就是事件标志组。 0x01 事件标志组 事…

FusionCharts等产品简介

以前做柱状图、饼形图等图表都是根据数据绘制出来的静态图&#xff0c;偶然看到别人的一套系统&#xff0c;居然可以让柱状图的柱子动画般的逐个出现&#xff0c;效果还是很不错的。不要跟我抬杠说不就是展现数据嘛&#xff0c;静态图表有什么不好&#xff0c;要知道用户一般可…

c#foreach循环_C#| 使用foreach循环打印整数数组

c#foreach循环Given an integer array and we have to print its elements using "foreach loop" in C#. 给定一个整数数组&#xff0c;我们必须在C&#xff03;中使用“ foreach循环”打印其元素 。 Syntax for foreach loop: foreach循环的语法&#xff1a; fore…

Eclipse和Tomcat绑定并且将上传资源到Tomcat上

步骤如下&#xff1a; 创建一个Dynamic Web Project&#xff08;图一&#xff09; Target runtime 选择Apache Tomcat v7.0版本&#xff08;图二&#xff09; 切记要选择 v7.0 和2.5 &#xff08;若没有图二选项见图三&#xff09; 然后&#xff0c;点击window --> Prefer…