Java Data Type Tutorial - Java Character .offsetByCodePoints (CharSequence seq, int index, int codePointOffset)








Syntax

Character.offsetByCodePoints(CharSequence seq, int index, int codePointOffset) has the following syntax.

public static int offsetByCodePoints(CharSequence seq,   int index,   int codePointOffset)

Example

In the following code shows how to use Character.offsetByCodePoints(CharSequence seq, int index, int codePointOffset) method.

public class Main {
//from  w  ww  .  j  a v  a  2 s .c  o m
   public static void main(String[] args) {
      CharSequence seq = "Hello World";
      int res = Character.offsetByCodePoints(seq, 3, 8);

      String str = "The index within the char sequence seq is " + res;

      System.out.println( str );
   }
}

The code above generates the following result.