Here you can find the source of lastIndexOf(char ch, String str)
public static int lastIndexOf(char ch, String str)
//package com.java2s; //License from project: Open Source License public class Main { public static int lastIndexOf(char ch, String str) { if (str.charAt(str.length() - 1) == ch) { return str.length() - 1; }//from w w w. j av a 2s . c o m if (str.length() <= 1) { return -1; } return lastIndexOf(ch, str.substring(0, str.length() - 1)); } }