← Docs
kotlin-stdlib / kotlin.text / clear

clear

Common
JS
Native
1.3
fun StringBuilder . clear ( ) : StringBuilder
(Common source) (JS source) (Native source)

Clears the content of this string builder making it empty and returns this instance.

import java.util.Locale
import kotlin.test.*

fun main(args: Array<String>) {
//sampleStart
val builder = StringBuilder()
builder.append("content").append(1)
println(builder) // content1

builder.clear()
println(builder) //
//sampleEnd
}
Stay in touch:
  • Contributing to Kotlin
  • Releases
  • Press Kit
  • Security
  • Blog
  • Issue Tracker
  • Brand assets
  • Careers
Supported and developed by JetBrains .
Kotlin™ is protected under the Kotlin Foundation
and licensed under the Apache 2 license .