stringbuffermodify.java

来自「StringBuffer类对象方法的使用。String和StringBuffer」· Java 代码 · 共 22 行

JAVA
22
字号
//例7.5
class StringBufferModify{
		public static void main(String argvs[]){
			StringBuffer sb = new StringBuffer("We will modify a StringBuffer	");
			System.out.println("Here is a StringBuffer Let's modify it.");
			System.out.println("Now the StringBuffer is \""+sb+"\"");
			char c = '!';
			double pi = .1415927;
			int p = 3;
			String a = "Pi = ";
			System.out.println("append a char 		:"+c);
			System.out.println("Now the StringBuffer is :\""+sb.append(c)+"\"");
			System.out.println("insert a string 			:"+a);
			System.out.println("Now the StringBuffer is :\""+sb.insert(sb.length(),a)+"\"");
			System.out.println("append a double num 		:"+p);
  			System.out.println("Now the StringBuffer is :\""+sb.append(p)+"\"");
  			System.out.println("append a double num 		:"+pi);
  			System.out.println("Now the StringBuffer is :\""+sb.append(pi)+"\"");
		}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?