Java Character codePointAt() methodThis Method has 3 types of syntax. Java Character codePointAt(char[] a, int index) methodThe codePointAt() method of Character class is used to return the code point at the given index of char array. If at a particular index, the char value in the char array is in the high surrogate range, the following index is less than the index of char array and if the char value at a given index is in the low surrogate range then the codepoint corresponding to this pair is returned. SyntaxParameterThe above method requires two parameters:
Return ValueThe codePointAt() method returns the value of character at the index. Example 1Output: This is the first program for the given method : 32 Example 2Output: Given String : javatpoint.com Character Value = 97 Character Value = 105 Example 3Output: The first string is = JAVA Character(unicode point) = 65 The second string is = TPOINT Character(unicode point) = 86 Example 4Output: Java is a unique language. Enter the desired index: 8 Result: 97 Java Character codePointAt(char[] a, int index, int limit) methodThe codePointAt(char[] a, int index, int limit) method of character class returns the code point at a given index of char array, where only element with index less than limit can be used. If at a particular index, the char value in the char array is in the high surrogate range, the following index is less than the limit. If the char value at a given index is in the low surrogate range, the code point corresponding to this pair is returned. SyntaxParameterThe above method requires three parameters:
Return ValueThis method returns the Unicode point at the given index. Example 5Output: Hello Unicode code point is : 108 Everyone Unicode code point is : 108 Example 6Output: The numbers are: '1', '2', '3', '4', '5' Unicode code point is 50 Example 7Output: Hello Unicode code point for Hello is 108 The numbers are: '1', '2', '3', '4', '5' Unicode code point for number is 108 Java Character codePointAt(CharSequence seq, int index) MethodThe codePointAt(CharSequence seq, int index) method of Character class returns the code point at a particular index of the charSequence. If at a particular index, the char value in the charSequence is in the high surrogate range, the following index would be lesser than the length of the charSequence. On the other hand, if the char value in the charSequence is in the low surrogate range, the supplementary code point corresponding to the given surrogate pair is returned. SyntaxParameterThe above method requires two parameters:
Return ValueThis method returns the Unicode code point at a particular index. Example 8Output: Java is secured The Unicode code point is 97 Example 9Output: Java is secured The Unicode code point for Java is 118 The numbers are: '1', '2', '3', '4', '5' The Unicode code point for number is 52 Example 10Output: Java is more portable The Unicode code point for Java is 118 Java is based on the concepts of OOPS. The Unicode code point for Java is 118 Next TopicJava-character-codepointbefore-method |