Here you can find the source of lastIndexOf(String string, char value, int startIndex, int count)
public static int lastIndexOf(String string, char value, int startIndex, int count)
//package com.java2s; //License from project: Open Source License public class Main { public static int lastIndexOf(String string, char value, int startIndex, int count) { int leftMost = startIndex + 1 - count; int rightMost = startIndex + 1; String substring = string.substring(leftMost, rightMost); int lastIndexInSubstring = substring.lastIndexOf(value); if (lastIndexInSubstring < 0) return -1; else/* w ww .jav a 2 s.com*/ return lastIndexInSubstring + leftMost; } public static int lastIndexOf(String string, String value, int startIndex, int count) { int leftMost = startIndex + 1 - count; int rightMost = startIndex + 1; String substring = string.substring(leftMost, rightMost); int lastIndexInSubstring = substring.lastIndexOf(value); if (lastIndexInSubstring < 0) return -1; else return lastIndexInSubstring + leftMost; } public static String substring(String string, int start, int length) { if (length < 0) throw new IndexOutOfBoundsException("Parameter length cannot be negative."); return string.substring(start, start + length); } }