Here you can find the source of lastIndexOf(char[] toBeFound, char[] array)
public static final int lastIndexOf(char[] toBeFound, char[] array)
//package com.java2s; /******************************************************************************* * Copyright (c) 2004, 2005 IBM Corporation and others. * 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://w ww. j a v a 2 s . c o m * IBM Corporation - initial API and implementation *******************************************************************************/ public class Main { public static final int lastIndexOf(char[] toBeFound, char[] array) { int j = toBeFound.length - 1; for (int i = array.length; --i >= 0;) { if (toBeFound[j] == array[i]) { if (--j == -1) return i; } else j = toBeFound.length - 1; } return -1; } }