Here you can find the source of lastIndexOf(CharSequence s, char c, int start, int end)
public static int lastIndexOf(CharSequence s, char c, int start, int end)
//package com.java2s; /******************************************************************************* * Copyright (c) 2012-2017 Codenvy, S.A. * 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 * * Contributors://from ww w.j ava 2 s . c o m * Codenvy, S.A. - initial API and implementation *******************************************************************************/ public class Main { /** * Returns the index within this string of the last occurrence of the * specified char, searching in specified range */ public static int lastIndexOf(CharSequence s, char c, int start, int end) { start = Math.max(start, 0); for (int i = Math.min(end, s.length()) - 1; i >= start; i--) { if (s.charAt(i) == c) { return i; } } return -1; } }