Question DSA-STR-0011
MediumWhy is building a long string with repeated += in a loop slow in Java?
- A.
Each += creates a new String object and copies the old contents, making it O(n²) overall
- B.
+= is not allowed on strings
- C.
Sign up free to see the answer and a step-by-step explanation.