Some string methods we can use in the program to get the required output.
Java String class provides different utility methods to perform any operations on the strings. Following are some string methods we can use in the program to get the required output. Before that following image is an index of each character in the string. In string index position starts with 0 and ends with string length – 1.
1. charAt()
This method is used to find the character present in the string at particular the index.
Example :
2. codePointAt()
This returns the Unicode of the character for the specified index.
Example :
3. codePointBefore()
Returns the Unicode of the character before the specified index. If we get the Unicode of the character before 5 then it should return the Unicode for the character at 4 as shown in the below example.
4. codePointCount()
This returns number of Unicode points in the given range.
The range is from firstIndex to (lastIndex – 1) that is if we gave a range from 2, 5 then it will calculate the Unicode for string “two” for the main string “ugtworld”.