java中如何向一个字符串中添加字符呢?
下文笔者讲述向字符串中添加字符的方法分享,如下所示:
实现思路:
使用StringBuffer对象的相应的insert方法
即可向一个字符串中添加字符
例
package com.java265.other;
public class Test16 {
/**
* java265.com 示例程序
*
* @throws Exception
*/
public static void main(String[] args) throws Exception {
StringBuffer str = new StringBuffer();
str.append("this is my website");
str.append("java265.com");
System.out.println(str);
}
}
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。


