MyClass.java
 

public class MyClass {
  public static void main(String[] args) {
    String myStr = "Hello";
    int result = myStr.codePointCount(0, 5);
    System.out.println(result);
  }
}

Result:
5