博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java StringBuffer CharSequence subSequence(int spos,int epos)方法与示例
阅读量:2530 次
发布时间:2019-05-11

本文共 2285 字,大约阅读时间需要 7 分钟。

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){    }

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)); }}

Output

输出量

D:\Programs>javac StringBufferClass.javaD:\Programs>java StringBufferClassThe result will be after implementing method is : java.util is a package

翻译自:

转载地址:http://tapzd.baihongyu.com/

你可能感兴趣的文章
iOS开发网络篇—XML数据的解析
查看>>
[BZOJ4303]数列
查看>>
数据库TCPIP协议开了,但还是远程连不上
查看>>
一般处理程序在VS2012中打开问题
查看>>
C语言中的++和--
查看>>
thinkphp3.2.3入口文件详解
查看>>
POJ 1141 Brackets Sequence
查看>>
Ubuntu 18.04 root 使用ssh密钥远程登陆
查看>>
linux 单机跨进程通信
查看>>
Servlet和JSP的异同。
查看>>
虚拟机centOs Linux与Windows之间的文件传输
查看>>
ethereum(以太坊)(二)--合约中属性和行为的访问权限
查看>>
IOS内存管理
查看>>
监听系统键盘的方法
查看>>
Mysql两个引擎对比
查看>>
测试书籍推荐
查看>>
php魔术方法
查看>>
BZOJ4025 : 二分图
查看>>
SQL server中的SQL语句拼接
查看>>
17、生命周期-BeanPostProcessor在Spring底层的使用
查看>>