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

  • برمجة سكالا

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.

الأجوبة

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
هل كان المحتوى مفيد؟

معلومات ذات صلة

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...