Java performance of StringBuilder append chains
- by ultimate_guy
In Java, if I am building a significant number of strings, is there any difference in performance in the following two examples?
StringBuilder sb = new StringBuilder();
for (int i = 0; i < largeNumber; i++) {
sb.append(var[i]);
sb.append('=');
sb.append(value[i]);
sb.append(',');
}
or
StringBuilder sb = new StringBuilder();
for (int i = 0; i < largeNumber; i++) {
sb.append(var[i]).append('=').append(value[i]).append(',');
}
Thanks!