62,614
社区成员
发帖
与我相关
我的任务
分享
str+=str;//立马挂掉
String str = "text abcdefg a";
int cnt = 0;
try{
while(true){
cnt++;
//str += str;
str = str + str;
}
}catch(Error e){
e.printStackTrace();
System.out.println("次数: " + cnt);
}
String string = "text abcdefg a";
int i = 0;
try {
for (;;) {
i++;
string = new StringBuilder().append(string).append(string)
.toString();
}
} catch (Error error) {
error.printStackTrace();
System.out.println(new StringBuilder().append("\u6b21\u6570: ")
.append
(i).toString());
}
public class TestPlus {
public static void main(String[] args) {
String str = "_ok_";
int count = 0;
try {
while (true) {
count++;
str += str;// 情况1
// str = str + str; //情况2
System.out.println(str); //输出语句
}
} catch (Error e) {
System.out.println(count);
e.printStackTrace();
}
System.out.println("No:" + count);
}
}