Q:

Write a Scala program to remove the character in a given position of a given string. The given position will be in the range 0...string length -1 inclusive

0

Write a Scala program to remove the character in a given position of a given string. The given position will be in the range 0...string length -1 inclusive.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

object scala_basic {
  def test(str: String, n: Int): String = 
    {
     str.take(n) + str.drop(n + 1)
    }    
   def main(args: Array[String]): Unit = {
      println("Result: " + test("Scala", 1));
      println("Result: " + test("Scala", 0));
      println("Result: " + test("Scala", 4));
    }
}

Sample Output:
Result: Sala
Result: cala
Result: Scal

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now