public int lastIndexOf(String subString,int start){
  int count=length();
  int subCount=subString.length();
  if (subCount <= count && start >= 0) {
    if (subCount > 0) {
      if (start > count - subCount) {
        start=count - subCount;
      }
      char[] target=subString.toCharArray();
      int subOffset=0;
      char firstChar=target[subOffset];
      int end=subOffset + subCount;
      while (true) {
        int i=lastIndexOf(firstChar,start);
        if (i == -1) {
          return -1;
        }
        int o1=i, o2=subOffset;
        while (++o2 < end && charAt(++o1) == target[o2]) {
        }
        if (o2 == end) {
          return i;
        }
        start=i - 1;
      }
    }
    return start < count ? start : count;
  }
  return -1;
}

public int lastIndexOf ( String subString , int start ) { int count = length ( ) ; int subCount = subString . length ( ) ; if ( subCount <= count && start >= 0 ) { if ( subCount > 0 ) { if ( start > count - subCount ) { start = count - subCount ; } char [ ] target = subString . toCharArray ( ) ; int subOffset = 0 ; char firstChar = target [ subOffset ] ; int end = subOffset + subCount ; while ( true ) { int i = lastIndexOf ( firstChar , start ) ; if ( i == - 1 ) { return - 1 ; } int o1 = i , o2 = subOffset ; while ( ++ o2 < end && charAt ( ++ o1 ) == target [ o2 ] ) { } if ( o2 == end ) { return i ; } start = i - 1 ; } } return start < count ? start : count ; } return - 1 ; }
searches in this string for the index of the specified string . the search for the string starts at the specified offset and moves towards the beginning of this string .
