W3cubDocs

/Kotlin

clear

Platform and version requirements: JVM (1.3)
fun StringBuilder.clear(): StringBuilder

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

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
}

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/java.lang.-string-builder/clear.html