StringBuilder 小结

Categories: Java; Tagged with: ; @ February 1st, 2009 15:54
//----------------------以下待删除--------------
//	TODO 学习后删除;
	public static String getTestString() {
		StringBuilder sb = new StringBuilder();//新建一个SB
		sb.append("Print: ");
		for(int i=0; i < 10; i++) {
			if(i != 0) {
				sb.append(", ");
				// s += ", "; //BAD!
			}
			sb.append(i);
			// s += i; //BAD!
		}
		sb.append("a").append("b").append("C").
		append("w"); 
		return sb.toString();
		System.out.println(sb.toString());
		// return s; // BAD!
		// return "Id: " + id; // 简单情况下使用"+"链接, OK
	}



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.