class Ideone
{
{
int data1 = 5;
double data2 = 100.001;
int data4 = 25;
StringBuilder sb = new StringBuilder();
sb.append(data1);
sb.append(data3);
// to go to next line
sb.append("\n");
// append can be chained together
sb.append(data2).append(data3).append(data5).append("\n");
for(int i=0; i<2; i++)
sb.append(i).append("*2 = ").append(i*2).append("\n");
for(int i=2; i<4; i++)
sb.append(i + "^2 = " + i*i + "\n");
// print the StringBuffer at the end
}
}
Y2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCWludCBkYXRhMSA9IDU7CgkJZG91YmxlIGRhdGEyID0gMTAwLjAwMTsKCQlTdHJpbmcgZGF0YTMgPSAiSGVsbG8iOwoJCWludCBkYXRhNCA9IDI1OwoJCVN0cmluZyBkYXRhNSA9ICJXb3JsZCI7CgkJCgkJU3RyaW5nQnVpbGRlciBzYiA9IG5ldyBTdHJpbmdCdWlsZGVyKCk7CgkJCgkJc2IuYXBwZW5kKGRhdGExKTsKCQlzYi5hcHBlbmQoZGF0YTMpOwoJCQoJCS8vIHRvIGdvIHRvIG5leHQgbGluZQoJCXNiLmFwcGVuZCgiXG4iKTsKCQkKCQkvLyBhcHBlbmQgY2FuIGJlIGNoYWluZWQgdG9nZXRoZXIKCQlzYi5hcHBlbmQoZGF0YTIpLmFwcGVuZChkYXRhMykuYXBwZW5kKGRhdGE1KS5hcHBlbmQoIlxuIik7CgkJCgkJZm9yKGludCBpPTA7IGk8MjsgaSsrKQoJCQlzYi5hcHBlbmQoaSkuYXBwZW5kKCIqMiA9ICIpLmFwcGVuZChpKjIpLmFwcGVuZCgiXG4iKTsKCQkKCQlmb3IoaW50IGk9MjsgaTw0OyBpKyspCgkJCXNiLmFwcGVuZChpICsgIl4yID0gIiArIGkqaSArICJcbiIpOwoJCQkKCQkvLyBwcmludCB0aGUgU3RyaW5nQnVmZmVyIGF0IHRoZSBlbmQKCQlTeXN0ZW0ub3V0LnByaW50bG4oc2IpOwoJfQp9