java初学--stringbuilder

xiaoxiao2021-02-28  80

1.append()方法

该方法用于向字符串生成器中追加内容。

append(content)

2.insert(int offset,arg)

该方法用于向字符串生成器中的制定位置插入数据内容

insert(int offset,arg)

public class bf { public static void main(String []args) { StringBuilder bb=new StringBuilder("hello"); bb.insert(5,"word"); System.out.println(bb.toString()); } }//输出信息为helloword

3.detele(int start,int end)

delete(int start,int end)

public class bf { public static void main(String []args) { StringBuilder bb=new StringBuilder("StringBuilder"); bb.delete(5,10); System.out.println(bb.toString()); } }//输出信息为Strinder

转载请注明原文地址: https://www.6miu.com/read-79369.html

最新回复(0)