Java StringBuffer CharSequence subSequence(int spos,int epos)方法与示例
StringBuffer类CharSequence subSequence(int spos,int epos) (StringBuffer Class CharSequence subSequence(int spos, int epos))
This method is available in package java.lang.StringBuffer.subSequence(int spos , int epos ).
软件包java.lang.StringBuffer.subSequence(int spos,int epos)中提供了此方法。
This method is used to return a character sequence that is a substring in the given StringBuffer object and substring starts from spos(Starting position) and ends with epos(Ending position).
此方法用于返回一个字符序列,该字符序列是给定StringBuffer对象中的子字符串,并且子字符串从spos (起始位置)开始,以epos (结束位置)结束。
The starting position (spos) will be the part of substring i.e. it is included in the returning substring and ending position(epos) will not be the part of substring i.e. it is excluded in the returning substring.
起始位置( spos )将是子字符串的一部分,即它包含在返回的子字符串中,结束位置( epos )将不是子字符串的一部分,即它将被排除在返回的子字符串中。
Syntax:
句法:
CharSequence subSequence(int spos , int epos){ }[/code]
Parameter(s):
参数:
We pass only two objects in the method of the StringBuffer i.e. spos(starting position), epos(ending position). The returning substring is in between spos and epos.
我们仅在StringBuffer方法中传递两个对象,即spos (开始位置), epos (结束位置)。 返回的子字符串在spos和epos之间。
Return value:
返回值:
The return type of this method is CharSequence that means this method returns the character sequence of the given StringBuffer object.
此方法的返回类型为CharSequence ,这意味着该方法返回给定StringBuffer对象的字符序列。
Java程序演示subSequence()方法的示例 (Java program to demonstrate example of subSequence() method)
import java.lang.StringBuffer; public class StringBufferClass { public static void main(String[] args) { StringBuffer sb = new StringBuffer(" java.util is a package of Java "); // use subSequence(int spos , int epos) // it will retrieve character sequence between // spos and epos with the given string in the method. // Display result after implementing subSequence(0,23) // i.e. "java.util is a package" will be returned // by the StringBuffer object "java.util is a package of Java" System.out.println("The result will be after implementing method is :" + sb.subSequence(0, 23)); } }[/code]
Output
输出量
D:\Programs>javac StringBufferClass.java D:\Programs>java StringBufferClass The result will be after implementing method is : java.util is a package[/code]
- Java StringBuffer.delete()方法
- Java——String和StringBuffer/StringBuilder字符串的常用方法
- java实现字符串转String数组的方法示例
- Java String方法获取字符出现次数及字符最大相同部分示例
- Java中String StringBuffer常用方法
- 【String类】【StringBuffer & StringBuilder】【常见方法以及示例】【包装类】
- java.lang.StringBuffer.append(char[] str)方法实例
- Java StringBuffer.setLength()方法
- JAVA String转化成java.sql.date和java.sql.time方法示例
- Java StringBuffer.substring(int start, int end)方法
- java StringBuffer的length()和capacity()方法比较
- java标准库中ByteBuffer转String的方法
- Java String字符串最常见方法速查手册+代码示例详解
- Java String.Format() 方法及参数说明
- JAVA String.format 方法使用介绍
- java int 转为string的三种方法
- 不依赖java的:String.split方法分割字符串
- java窗体运行时最大化及关闭方法示例
- 常用java String方法(积累中)
- java中判断string是否为空的三种方法——效率比较