Java Character codePointBefore() MethodThis Method has 3 types of syntax. Java codePointBefore(char[] a, int index) methodThe codePointBefore(char[] a, int index) method of Character class returns the code point for the given index of the char array. If the char value at (index-1) in the char array is in the low surrogate range, index-2 is not negative. If the char value at (index-2) in the char array is in the high surrogate range, the supplementary code point to this surrogate pair is returned. Otherwise, the char value at (index-1) is returned. SyntaxParameterThe above method requires two parameters:
Return ValueThe codePointBefore(char[] a, int index) method returns the Unicode point before the given index. Example 1Output: Welcome to java tutorials. The unicode point is given as = 87 Example 2Output: Welcome to java tutorials. Unicode code point before the string is 87 The numbers are: '1', '2', '3', '4', '5' Unicode code point before the number is 108 Example 3Output: Enter the desired index: 3 Result is given by:39 Java Character codePointBefore(char[] a, int index, int start)MethodThe codePointBefore(char[] a, int index, int start) method of Character class is used to return the code point preceding the given index of the char array where only those array elements with index greater than or equal to start can be used. If in the char array, the char value at (index-1) is in the low surrogate range, (index-2) is not less than start. On the other hand, if the char value at (index-2) is in the high surrogate range, the supplementary code point corresponding to the surrogate pair is returned. Otherwise, it returned the char value at (index-1). SyntaxParameterThe above method requires three parameters:
Return ValueThe codePointBefore(Char[] a, int index, int start) method returns the Unicode code point before the index. Example 4Output: Welcome to our tutorial site. The unicode code point is 67 Example 5Output: Welcome to our tutorial site. The unicode code point for alphabets: The unicode code point is 67 The unicode code point for numbers: The unicode code point is 51 Example 6Output: The numbers are: '1', '2', '3', '4' The unicode code point is 51 The numbers are: '5', '6', '7', '8' The unicode code point is 55 Java Character codePointBefore(charSequence seq, int index) MethodThe codePointBefore(charSequence seq, int index) method of Character class is used to return the code point preceding the given index of the charSequence. If in the char sequence, the char value at (index-1) is in the low surrogate range, (index-2) is not negative. On the other hand, if the char value at (index-2) is in the high surrogate range, the supplementary code point corresponding to this surrogate pair is returned. Otherwise, the char value at (index-1) is returned. SyntaxParameterThe above method requires two parameters:
Return ValueThe codePointBefore(charaSequence seq, int index) method returns the Unicode code point value before the given index. Example 7Output: Welcome to our tutorial site: The Unicode code point for Java is 108 The Unicode code point for Everyone is 101 Example 8Output: The string is: Java The Unicode code point for Java is 108 The numbers are: '1', '2', '3', '4' The unicode code point for numbers is 108 Example 9Output: The numbers are: '1', '2', '3', '4': The unicode code point for first four numbers is 51 The numbers are: '1', '2', '3', '4': The unicode code point for second four numbers is 55 Next TopicJava-character-codepointcount-method |