kotlin 警告「warning: ‘toUpperCase(): String’ is deprecated. Use uppercase() instead.」の解決方法

kotlin 警告「warning: ‘toUpperCase(): String’ is deprecated. Use uppercase() instead.」の解決方法

kotlinで、警告「warning: ‘toUpperCase(): String’ is deprecated. Use uppercase() instead.」の解決方法を記述してます。「toUpperCase」が非推奨となっているため発生します。

環境

  • OS windows11 home
  • java 17.0.2
  • kotlin 1.6.10-release-923

警告全文

以下のコードで発生。

fun main() {    

    println("kotlin".toUpperCase())
    // KOTLIN   

}

警告メッセージ

hello.kt:3:22: warning: 'toUpperCase(): String' is deprecated. Use uppercase() instead.
    println("kotlin".toUpperCase())

原因

toUpperCaseは非推奨なため

対処法

「uppercase」を使用する

fun main() {    

    println("kotlin".uppercase())
    // KOTLIN   

}