一:源程序:

package javapTest;

public class JavapTip {

/**
*
@param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String strWithStr = JavapTip.withStrings(5);
String strWithStrBuf
= JavapTip.withStringBuffer(5);

System.out.println(
"strWithStr="+strWithStr);
System.out.println(
"strWithStrBuf="+strWithStrBuf);
}
private static String withStrings(int count) {
String s
= "";
for (int i = 0; i < count; i++) {
s
+= i;
}
return s;
}
private static String withStringBuffer(int count) {
StringBuffer sb
= new StringBuffer();
for (int i = 0; i < count; i++) {
sb.append(i);
}
return sb.toString();
}

}

相关文章: