Kotlin String Case Example

Kotlin has methods for working with the case of string characters.

Kotlin String Case Example

The example presents four methods: 
  • capitalize()
  • toUpperCase()
  •  toLowerCase()
  • decapitalize()

package net.javaguides.kotlin.examples

fun main(args: Array < String > ) {

    val s = "source code examples"

    println(s.capitalize())
    println(s.toUpperCase())
    println(s.toLowerCase())

    println("my website ".decapitalize())
}
Output:
Source code examples
SOURCE CODE EXAMPLES
source code examples
my website 


Comments