How to check if a string starts with a specified substring in Kotlin

1 Answer

0 votes
fun main() {
    val str = "Kotlin Programming Language";
    val substr = "Kotlin"

    if (str.startsWith(substr)) {
        println("yes")
    } else {
        println("no")
    }
}

  
   
/*
run:

yes
 
*/

 



answered Feb 10, 2025 by avibootz
...