How to remove the first and the last character from a string in Scala

1 Answer

0 votes
object RemoveTheFirstAndLastCharacterOfAString_Scala {
  def main(args: Array[String]): Unit = {
    var s = "scala programming"

    // Slice the string from index 1 to the second last character
    s = s.substring(1, s.length - 1)

    println(s)
  }
}
 
   
/*
           
run:
     
cala programmin
       
*/

 



answered Sep 7, 2024 by avibootz
...