import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
public static void main
(String[] args
) {
long b
= System.
currentTimeMillis(); for(int i = 0; i < 50000; i++) {
a += 'a';
}
System.
out.
println("String tardo: " + (System.
currentTimeMillis() - b
) + " Milisegundos añadiendo 50.000 caracteres"); StringBuilder st = new StringBuilder();
b
= System.
currentTimeMillis(); for(int i = 0; i < 50000; i++) {
st.append('a');
}
System.
out.
println("StringBuilder tardo: " + (System.
currentTimeMillis() - b
) + " Milisegundos añadiendo 50.000 caracteres");
st = new StringBuilder();
for(int i = 0; i < 1000000; i++) {
st.append('a');
}
System.
out.
println("StringBuilder tardo: " + (System.
currentTimeMillis() - b
) + " Milisegundos añadiendo 1.000.000 caracteres"); }
}
CmltcG9ydCBqYXZhLnV0aWwuKjsKaW1wb3J0IGphdmEubGFuZy4qOwppbXBvcnQgamF2YS5pby4qOwoKY2xhc3MgTWFpbiB7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykgIHsKCQkKCQlTdHJpbmcgYSA9ICIiOwoJCWxvbmcgYiA9IFN5c3RlbS5jdXJyZW50VGltZU1pbGxpcygpOyAKCQlmb3IoaW50IGkgPSAwOyBpIDwgNTAwMDA7IGkrKykgewoJCQlhICs9ICdhJzsKCQl9CgkJU3lzdGVtLm91dC5wcmludGxuKCJTdHJpbmcgdGFyZG86ICIgKyAoU3lzdGVtLmN1cnJlbnRUaW1lTWlsbGlzKCkgLSBiKSArICIgTWlsaXNlZ3VuZG9zIGHDsWFkaWVuZG8gNTAuMDAwIGNhcmFjdGVyZXMiKTsKCQlTdHJpbmdCdWlsZGVyIHN0ID0gbmV3IFN0cmluZ0J1aWxkZXIoKTsKCQliID0gU3lzdGVtLmN1cnJlbnRUaW1lTWlsbGlzKCk7IAoJCWZvcihpbnQgaSA9IDA7IGkgPCA1MDAwMDsgaSsrKSB7CgkJCXN0LmFwcGVuZCgnYScpOwoJCX0KCQlTeXN0ZW0ub3V0LnByaW50bG4oIl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