Here you can find the source of lastIndexOf(String what, String within)
public static int lastIndexOf(String what, String within)
//package com.java2s; /******************************************************************************* * Copyright (c) 2009 MATERNA Information & Communications. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html. For further * project-related information visit http://www.ws4d.org. The most recent * version of the JMEDS framework can be obtained from * http://sourceforge.net/projects/ws4d-javame. ******************************************************************************/ public class Main { public static int lastIndexOf(String what, String within) { if (what == null || within == null || what.length() == 0) { return -1; }/*ww w. ja va 2 s . co m*/ int i = 0; int lastI = -1; while ((i = within.indexOf(what, i)) != -1) { lastI = i++; } return lastI; } }