Q:

Write a Scala program to get the character (Unicode code point) at the given index within the String

0

Write a Scala program to get the character (Unicode code point) at the given index within the String.

All Answers

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

object Scala_String {
  def main(args: Array[String]): Unit = {
    val str = "w3resource - Scala";
    println(s"Original String : ${str}");
    // codepoint at index 1
    val val1 = str.codePointAt(1);
    // codepoint at index 12
    val val2 = str.codePointAt(9);
    // prints character at index1 in string
    println("Character(unicode point) = " + val1);
    // prints character at index9 in string
    println("Character(unicode point) = " + val2);
  }
}

Sample Output:

Original String : w3resource - Scala
Character(unicode point) = 51
Character(unicode point) = 101

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