Character.offsetByCodePoints() Method in java Last Updated : 19 Jul, 2022 Comments Improve Suggest changes Like Article Like Report The Character.offsetByCodePoints(CharSequence seq, int index, int codePointOffset) is an inbuilt method in java that returns the index within the given char sequence that is offset from the given index by codePointOffset code points. Unpaired surrogates within the text range given by index and codePointOffset count as one code point each. Syntax: public static int offsetByCodePoints(CharSequence seq, int index, int codePointOffset) Parameters: seq - the char sequenceindex - the index to be offsetcodePointOffset - the offset in code points Return value: This method of Character class returns the index within the char sequence. Exceptions: NullPointerException – if seq is null.IndexOutOfBoundsException – if index is negative or larger than the length of the char sequence, or if codePointOffset is positive and the subsequence starting with index has fewer than codePointOffset code points, or if codePointOffset is negative and the subsequence before index has fewer than the absolute value of codePointOffset code points. Below are the programs to illustrate the above mentioned method: Program 1: Java // Code to illustrate the offsetByCodePoints() method import java.lang.*; public class gfg { public static void main(String[] args) { // Create a CharSequence s and assign value CharSequence s = "Hello World"; // Result of offsetByCodePoints on s String str = "The index within the char sequence s is " + Character.offsetByCodePoints(s, 2, 6); // Print str value System.out.println(str); } } Output:The index within the char sequence s is 8 Program 2: Java // Code to illustrate the offsetByCodePoints() method import java.lang.*; public class gfg { public static void main(String[] args) { // Create a CharSequence s and assign value CharSequence s = "geeks for geeks"; // Result of offsetByCodePoints on s String str = "The index within the char sequence s is " + Character.offsetByCodePoints(s, 3, 8); // Print str value System.out.println(str); } } Output:The index within the char sequence s is 11 Comment More infoAdvertise with us Next Article Character.offsetByCodePoints() Method in java T Twinkl Bajaj Follow Improve Article Tags : Misc Java Java-lang package Java-Functions Java-Character +1 More Practice Tags : JavaMisc Similar Reads Character.offsetByCodePoints() in Java with Examples The Character.offsetByCodePoints(char[] a, int start, int count, int index, int codePointOffset) is an inbuilt method in Java that returns the index within the given char subarray that is offset from the given index by codePointOffset code points. The start and count arguments specify a subarray of 2 min read StringBuffer offsetByCodePoints() method in Java with Examples The offsetByCodePoints() method of StringBuffer class returns the index within this String contained by StringBuffer that is offset from the index passed as parameter by codePointOffset code points. Unpaired surrogates lies between index and codePointOffset count as one code point each. Syntax: publ 2 min read StringBuilder offsetByCodePoints() method in Java with Examples The offsetByCodePoints() method of StringBuilder class returns the index within this String contained by StringBuilder that is offset from the index passed as parameter by codePointOffset code points. Unpaired surrogates lies between index and codePointOffset count as one code point each. Syntax: pu 2 min read Java String charAt() Method String charAt() method in Java returns the character at the specified index in a string. The Index of the first character in a string is 0, the second character is 1, and so on. The index value should lie between 0 and length() - 1.If the index value is greater than or equal to the string length or 2 min read CharacterIterator setIndex() method in Java with Examples The setIndex() method of java.text.CharacterIterator interface in Java is used to set the current index that is to be read by this CharacterIterator. This method takes the index to be set as a parameter and sets the index of this CharacterIterator at that index and then it returns that character. Sy 1 min read Array setChar() method in Java The java.lang.reflect.Array.setChar() is an inbuilt method in Java and is used to change a specified char value to a specified index of a given object array. Syntax: Array.setChar(Object []array, int index, char value) Parameter: This method takes three parameters: array: This is an array of type Ob 3 min read Charset toString() method in Java with Examples The toString() method is a built-in method of the java.nio.charset returns a string which describes the charset involved. Syntax: public final String toString() Parameters: The function does not accepts any parameter. Return Value: The function returns a string describing this charset. Below is the 1 min read java.lang.Character Class Methods | Set 1 java.lang.Character Class wraps the value of a primitive data type char to an object of datatype Character. This object contains a single field having the data type char. This class provides several methods regarding character manipulations like converting them from lowercase to uppercase. Character 6 min read Character.isMirrored() method in Java The Character.isMirrored(int codePoint) is an inbuilt method in java that determines whether the specified character (Unicode code point) is mirrored according to the Unicode specification. Mirrored characters should have their glyphs horizontally mirrored when displayed in text that is right-to-lef 2 min read Like