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 the char array. Unpaired surrogates within the text range given by index and codePointOffset count as one code point each.
The offsetByCodePoints(char a, int start, int count, int index, int codePointOffset) method of Character class is static thus it should be accessed statically.
A non-static method is usually called by declaring method_name(argument). But in this case, since it is a static method, the class name is appended as a suffix, during the call. A compilation problem may be encountered if the java offsetByCodePoints() method is tried to be called in a non-static manner.
public static int offsetByCodePoints(char a, int start, int count, int index, int codePointOffset)
- a: the char array
- start: the index of the first char of the subarray
- count: the length of the subarray in chars
- index: the index to be offset
- codePointOffset: the offset in code points
Return value: This method returns an integer type value i.e., the index, within the subarray.
- NullPointerException: If a is null.
- IndexOutOfBoundsException: If start or count is negative, or if start + count is larger than the length of the given array, or if index is less than start or larger then start + count, or if codePointOffset is positive and the text range starting with index and ending with start + count – 1 has fewer than codePointOffset code points, or if codePointOffset is negative and the text range starting with start and ending with index – 1 has fewer than the absolute value of codePointOffset code points.
Below program illustrate the Character.offsetByCodePoints() method:
The index within the subarray is 3
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Java.util.LinkedList.poll(), pollFirst(), pollLast() with examples in Java
- Java lang.Long.builtcount() method in Java with Examples
- Java lang.Long.lowestOneBit() method in Java with Examples
- Java Deprecated API Scanner tool (jdepscan) in Java 9 with Examples
- Java.util.function.DoublePredicate interface in Java with Examples
- Java.util.Collections.disjoint() Method in java with Examples
- Java lang.Long.byteValue() method in Java with Examples
- Java.lang.Short toString() method in Java with Examples
- Java.util.function.IntPredicate interface in Java with Examples
- Java.util.function.LongPredicate interface in Java with Examples
- Java.util.function.BiPredicate interface in Java with Examples
- Java.util.Collections.rotate() Method in Java with Examples
- Java.util.BitSet class methods in Java with Examples | Set 2
- Java lang.Long.reverse() method in Java with Examples
- Java.util.concurrent.RecursiveTask class in Java with Examples
- Java.util.concurrent.Phaser class in Java with Examples
- Java.util.concurrent.RecursiveAction class in Java with Examples
- Java lang.Long.highestOneBit() method in Java with Examples
- Java lang.Long.numberOfLeadingZeros() method in Java with Examples
- Java lang.Long.numberOfTrailingZeros() method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.