Skip to content

Commit b312a48

Browse files
committed
Update koans/src/beginner/AboutStrings.java
1 parent cf014b5 commit b312a48

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎koans/src/beginner/AboutStrings.java‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ public void stringConcatenation() {
4646
}
4747

4848
@Koan
49-
public void efficientStringConcatenation() {
50-
// the above implicit string concatenation looks nice - but, it is expensive.
51-
// it creates a new string instance on each concatenation. here's a better alternative:
49+
public void stringBuilderCanActAsAMutableString() {
50+
// StringBuilder concatenation looks uglier, but is useful when you need a
51+
// mutable String like object. It used to be more efficient than using +,
52+
// to concatate numerous strings, however this is optimized in the compiler now.
53+
// Usually + concatenation is more appropriate than StringBuilder.
5254
assertEquals(new StringBuilder("one").append(" ").append("two").toString(), __);
5355
}
5456

0 commit comments

Comments
 (0)