Java Character codePointCount() MethodThis Method has 2 types of syntax. Java Character codePointCount(char[]a, int offset, int count) MethodThe codePointCount(char[]a, int offset, int count) method is used to return the number of Unicode code points in the sub array of the char array. The offset argument is the index of the first char in the given char array and the count argument indicates the length of the sub array. SyntaxParameterThe above method requires three parameters:
Return ValueThis method returns the number of Unicode code point in the specified sub array. Example 1Test it NowOutput: Welcome to our tutorial site: The result is given as: 2 Example 2Test it NowOutput: The alphabets are: 'a', 'b', 'c', 'd', 'e' The number of Unicode code point for alphabets are 4 The numbers are: '1', '2', '3', '4', '5' The number of Unicode code point for numbers are 3 Example 3Test it NowOutput: Hello everyone 6 is generated because method counts the first argument. Everyday is a fun day 2 is generated because method counts the second argument. Java Character codePointCount()MethodThe codePointCount(CharSequence seq, int beginIndex, int endIndex) method of Character class is used to return the number of Unicode code points in the text range of a particular char sequence. The text range begins from the beginIndex and ends at endIndex. SyntaxParameterThe above method requires three parameters:
Return ValueThe codePointCount(CharSequence seq, int beginIndex, int endIndex) method returns the number of Unicode code points in the specified text range. Example 4Test it NowOutput: This is a unique example! The result comes to be:25 Example 5Test it NowOutput: This is a unique example! The result comes to be:25 Hello World! Number of Unicode code points is 4 Example 6Test it NowOutput: This is a unique example! The result comes to be: 25 Java is a high level language! The result comes to be: 30 Java is based on the cocepts of OOPS! The result comes to be: 37
Next TopicJava Character
|