Java StringBuffer int codePointCount(int index1,int index 2)方法,包含示例
StringBuffer类int codePointCount(int index1,int index 2) (StringBuffer Class int codePointCount(int index1 , int index 2))
This method is available in package java.lang.StringBuffer.codePointCount(int index).
包java.lang.StringBuffer.codePointCount(int index)中提供了此方法。
This method is used to return the number of Unicode Codepoint at the specified range of index (i.e. it returns all the number of Unicode codepoint lies between index 1 and index 2) in the method.
此方法用于在方法的指定索引范围内返回Unicode代码点的数量(即,它返回位于索引1和索引2之间的所有Unicode代码点的数量)。
Index range will start from 0 to length()-1.
索引范围将从0到length()-1开始 。
This method does not raise an exception.
此方法不会引发异常。
Syntax:
句法:
int codePointCount(int index1 , int index2){ }[/code]
Parameter(s):
参数:
We pass two object in the method of the StringBuffer i.e index1 and index2.
我们在StringBuffer方法中传递了两个对象,即index1和index2 。
Return value:
返回值:
The return type of this method is int that means this method return the count of all Unicode codepoint lie between index1 and index2 and codepoint value is in number format.
此方法的返回类型为int ,这意味着此方法返回index1和index2之间的所有Unicode代码点的计数,并且代码点的值为数字格式。
Java程序演示codePointCount()方法的示例 (Java program to demonstrate example of codePointCount() method)
import java.lang.StringBuffer; public class StringBufferClass { public static void main(String[] args) { StringBuffer sb = new StringBuffer("Java is a pure OOPS"); // use codePointCount(int index1 , int index 2) // it will return the number of Unicode codepoint lies // between index 1 and index 2 int codepointcount = sb.codePointCount(2, 8); // Display result after implementing codePointCount(2,8) System.out.println("The result will be after implementing method codePointCount(2 , 8) is :" + codepointcount); sb = new StringBuffer("Current Version of Java is 8"); // use codePointCount(int index1 , int index2) // it will return the number of Unicode codepoint lies // between index 1 and index 2 //Display result after implementing codePointCount(3,9) System.out.println("The result will be after implementing method codePointCount(3,9) is :" + sb.codePointCount(3, 9)); } }[/code]
Output
输出量
D:\Programs>javac StringBufferClass.java D:\Programs>java StringBufferClass The result will be after implementing method codePointCount(2 , 8) is :6 The result will be after implementing method codePointCount(3,9) is :6[/code]
- 创建一个名为myinput.java的程序:包含从键盘读取 int、double、float、boolean、short、byte和string值的方法
- Java StringBuffer.substring(int start, int end)方法
- Java中字符串长度方法length()和codePointCount()区别
- JAVA String方法中public int indexOf(int ch)问题
- Java StringBuffer CharSequence subSequence(int spos,int epos)方法与示例
- Java:int 和 String 互相转换的多种方法
- java 校验数据是否为int、double、string类型的方法instanceof
- Java包含抽象方法的枚举类示例
- java中关于String的split(String regex, int limit) 方法
- java.lang.String.indexOf()方法
- [java] int和String互相转换的多种方法
- Java int和string互相转化方法
- eclipse Java文件打开异常解决方法 :java.lang.StringIndexOutOfBoundsException: String index out of range: 26
- java中int,char,string之间的相互转换方法
- Java替换int数组中重复数据的方法示例
- Java:int 和 String 互相转换的多种方法
- java中Object转换成int或String类型方法
- java中int类型转换成String类型的三种方法
- java中将Object转换成 String类型和int类型的方法 和Object数组转换成String数组的方法
- JAVA中int与String的相互转化方法和使用