class Main {
public static void main(String[] args) {
// appending to a String in a loop reallocates each time
var sb = new StringBuilder();
for (int i = 0; i < 5; i++) {
sb.append(i);
}
System.out.println(sb.toString());
}
}build text without a new object each step