int len = sequence.length(); if (index < 1 || index > len) throw new IndexOutOfBoundsException(); --index; char low = sequence.charAt(index); if (! isLowSurrogate(low) || --index < 0) return low; char high = sequence.charAt(index); if (! isHighSurrogate(high)) return low; return toCodePoint(high, low);
return codePointBefore(chars, index, 1);
  public static int codePointBefore(CharSequence sequence, int index)  {    int len = sequence.length();    if (index < 1 || index > len)      throw new IndexOutOfBoundsException();    --index;    char low = sequence.charAt(index);    if (! isLowSurrogate(low) || --index < 0)      return low;    char high = sequence.charAt(index);    if (! isHighSurrogate(high))      return low;    return toCodePoint(high, low);  }