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

Java Programming Language / String in java

1963

Program:

public class Exercise2 {

   public static void main(String[] args) {

    String str = "atnyla.com";
    System.out.println("Original String : " + str);

    // codepoint at index 1
    int val1 = str.codePointAt(1);

    // codepoint at index 9
    int val2 = str.codePointAt(9);

    // prints character at index1 in string
    System.out.println("Character(unicode point) = " + val1);
    // prints character at index9 in string
    System.out.println("Character(unicode point) = " + val2);
  }
}

Output:

Original String : atnyla.com
Character(unicode point) = 116
Character(unicode point) = 109
Press any key to continue . . .

Explanation:

None

This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.