Java String.offsetByCodePoints(int index, int codePointOffset)

Syntax

String.offsetByCodePoints(int index, int codePointOffset) has the following syntax.

public int offsetByCodePoints(int index,   int codePointOffset)

Example

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


/*from  w  w  w.  j a  v  a 2  s . co  m*/

public class Main {

  public static void main(String[] args) {
  
    String str = "java2s.com";
    System.out.println("string = " + str);

    // returns the index within this String
    int retval = str.offsetByCodePoints(2, 4);
    // prints the index
    System.out.println("index = " + retval);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable