How to remove the first N characters from a string in Kotlin

1 Answer

0 votes
fun main() {
    var str = "abcdefghijklmnop"
    val N = 7

    // Slice the string starting from index N
    str = str.substring(N)

    println(str)
}

   
      
/*
run:

hijklmnop
  
*/

 



answered Apr 24, 2025 by avibootz
...