Complete the code to create a new StringBuilder instance.
val sb = [1]()Use StringBuilder() to create a new instance for efficient string concatenation.
Complete the code to append the word "Hello" to the StringBuilder.
sb.[1]("Hello")
The append method adds text to the end of the StringBuilder.
Fix the error in the code to convert the StringBuilder content to a String.
val result = sb.[1]()The correct method to get the string from StringBuilder is toString().
Fill both blanks to build a string with numbers 1 to 3 separated by commas.
val sb = StringBuilder() for (i in 1..3) { sb.[1](i) if (i [2] 3) sb.append(", ") }
Use append to add numbers and commas. The condition i < 3 avoids adding a comma after the last number.
Fill all three blanks to create a StringBuilder, append "Kotlin", and convert to String.
val [1] = [2]() [1].append("Kotlin") val result = [1].toString()
We name the variable sb, create a StringBuilder(), and use sb to append and convert to string.