Here you can find the source of lastIndexOf(int[] array, int intToFind)
public static int lastIndexOf(int[] array, int intToFind)
//package com.java2s; //License from project: Open Source License public class Main { public static int lastIndexOf(int[] array, int intToFind) { return lastIndexOf(array, intToFind, 2147483647); }/*from w w w . j a v a 2s . c om*/ public static int lastIndexOf(int[] array, int[] arrayToFind) { return lastIndexOf(array, arrayToFind, 2147483647); } public static int lastIndexOf(int[] array, int intToFind, int startIndex) { if (array == null) { return -1; } else if (startIndex < 0) { return -1; } else { if (startIndex >= array.length) { startIndex = array.length - 1; } for (int i = startIndex; i >= 0; --i) { if (intToFind == array[i]) { return i; } } return -1; } } public static int lastIndexOf(int[] array, int[] arrayToFind, int startIndex) { if (array != null && arrayToFind != null) { int sourceLength = array.length; int targetLength = arrayToFind.length; int rightIndex = sourceLength - targetLength; if (startIndex < 0) { return -1; } else { if (startIndex > rightIndex) { startIndex = rightIndex; } if (targetLength == 0) { return startIndex; } else { int lastIndex = targetLength - 1; int last = arrayToFind[lastIndex]; int min = targetLength - 1; int i = min + startIndex; while (true) { while (i < min || array[i] == last) { if (i < min) { return -1; } int j = i - 1; int start = j - (targetLength - 1); int var12 = lastIndex - 1; do { if (j <= start) { return start + 1; } } while (array[j--] == arrayToFind[var12--]); --i; } --i; } } } } else { return -1; } } public static int lastIndexOf(short[] array, short shortToFind) { return lastIndexOf(array, shortToFind, 2147483647); } public static int lastIndexOf(short[] array, short[] arrayToFind) { return lastIndexOf(array, arrayToFind, 2147483647); } public static int lastIndexOf(short[] array, short shortToFind, int startIndex) { if (array == null) { return -1; } else if (startIndex < 0) { return -1; } else { if (startIndex >= array.length) { startIndex = array.length - 1; } for (int i = startIndex; i >= 0; --i) { if (shortToFind == array[i]) { return i; } } return -1; } } public static int lastIndexOf(short[] array, short[] arrayToFind, int startIndex) { if (array != null && arrayToFind != null) { int sourceLength = array.length; int targetLength = arrayToFind.length; int rightIndex = sourceLength - targetLength; if (startIndex < 0) { return -1; } else { if (startIndex > rightIndex) { startIndex = rightIndex; } if (targetLength == 0) { return startIndex; } else { int lastIndex = targetLength - 1; short last = arrayToFind[lastIndex]; int min = targetLength - 1; int i = min + startIndex; while (true) { while (i < min || array[i] == last) { if (i < min) { return -1; } int j = i - 1; int start = j - (targetLength - 1); int var12 = lastIndex - 1; do { if (j <= start) { return start + 1; } } while (array[j--] == arrayToFind[var12--]); --i; } --i; } } } } else { return -1; } } public static int lastIndexOf(byte[] array, byte byteToFind) { return lastIndexOf(array, byteToFind, 2147483647); } public static int lastIndexOf(byte[] array, byte[] arrayToFind) { return lastIndexOf(array, arrayToFind, 2147483647); } public static int lastIndexOf(byte[] array, byte byteToFind, int startIndex) { if (array == null) { return -1; } else if (startIndex < 0) { return -1; } else { if (startIndex >= array.length) { startIndex = array.length - 1; } for (int i = startIndex; i >= 0; --i) { if (byteToFind == array[i]) { return i; } } return -1; } } public static int lastIndexOf(byte[] array, byte[] arrayToFind, int startIndex) { if (array != null && arrayToFind != null) { int sourceLength = array.length; int targetLength = arrayToFind.length; int rightIndex = sourceLength - targetLength; if (startIndex < 0) { return -1; } else { if (startIndex > rightIndex) { startIndex = rightIndex; } if (targetLength == 0) { return startIndex; } else { int lastIndex = targetLength - 1; byte last = arrayToFind[lastIndex]; int min = targetLength - 1; int i = min + startIndex; while (true) { while (i < min || array[i] == last) { if (i < min) { return -1; } int j = i - 1; int start = j - (targetLength - 1); int var12 = lastIndex - 1; do { if (j <= start) { return start + 1; } } while (array[j--] == arrayToFind[var12--]); --i; } --i; } } } } else { return -1; } } public static int lastIndexOf(double[] array, double doubleToFind) { return lastIndexOf(array, doubleToFind, 2147483647, 0.0D); } public static int lastIndexOf(double[] array, double doubleToFind, double tolerance) { return lastIndexOf(array, doubleToFind, 2147483647, tolerance); } public static int lastIndexOf(double[] array, double[] arrayToFind) { return lastIndexOf(array, arrayToFind, 2147483647, 0.0D); } public static int lastIndexOf(double[] array, double[] arrayToFind, double tolerance) { return lastIndexOf(array, arrayToFind, 2147483647, tolerance); } public static int lastIndexOf(double[] array, double doubleToFind, int startIndex) { return lastIndexOf(array, doubleToFind, startIndex, 0.0D); } public static int lastIndexOf(double[] array, double doubleToFind, int startIndex, double tolerance) { if (array == null) { return -1; } else if (startIndex < 0) { return -1; } else { if (startIndex >= array.length) { startIndex = array.length - 1; } double min = doubleToFind - tolerance; double max = doubleToFind + tolerance; for (int i = startIndex; i >= 0; --i) { if (array[i] >= min && array[i] <= max) { return i; } } return -1; } } public static int lastIndexOf(double[] array, double[] arrayToFind, int startIndex) { return lastIndexOf(array, arrayToFind, startIndex, 0.0D); } public static int lastIndexOf(double[] array, double[] arrayToFind, int startIndex, double tolerance) { if (array != null && arrayToFind != null) { int sourceLength = array.length; int targetLength = arrayToFind.length; int rightIndex = sourceLength - targetLength; if (startIndex < 0) { return -1; } else { if (startIndex > rightIndex) { startIndex = rightIndex; } if (targetLength == 0) { return startIndex; } else { int lastIndex = targetLength - 1; double lastMin = arrayToFind[lastIndex] - tolerance; double lastMax = arrayToFind[lastIndex] + tolerance; int min = targetLength - 1; int i = min + startIndex; while (true) { while (i < min || array[i] >= lastMin && array[i] <= lastMax) { if (i < min) { return -1; } int j = i - 1; int start = j - (targetLength - 1); int var17 = lastIndex - 1; do { if (j <= start) { return start + 1; } } while (Math.abs(array[j--] - arrayToFind[var17--]) <= tolerance); --i; } --i; } } } } else { return -1; } } public static int lastIndexOf(float[] array, float floatToFind) { return lastIndexOf(array, floatToFind, 2147483647, 0.0F); } public static int lastIndexOf(float[] array, float floatToFind, float tolerance) { return lastIndexOf(array, floatToFind, 2147483647, tolerance); } public static int lastIndexOf(float[] array, float[] arrayToFind) { return lastIndexOf(array, arrayToFind, 2147483647, 0.0F); } public static int lastIndexOf(float[] array, float[] arrayToFind, float tolerance) { return lastIndexOf(array, arrayToFind, 2147483647, tolerance); } public static int lastIndexOf(float[] array, float floatToFind, int startIndex) { return lastIndexOf(array, floatToFind, startIndex, 0.0F); } public static int lastIndexOf(float[] array, float floatToFind, int startIndex, float tolerance) { if (array == null) { return -1; } else if (startIndex < 0) { return -1; } else { if (startIndex >= array.length) { startIndex = array.length - 1; } float min = floatToFind - tolerance; float max = floatToFind + tolerance; for (int i = startIndex; i >= 0; --i) { if (array[i] >= min && array[i] <= max) { return i; } } return -1; } } public static int lastIndexOf(float[] array, float[] arrayToFind, int startIndex) { return lastIndexOf(array, arrayToFind, startIndex, 0.0F); } public static int lastIndexOf(float[] array, float[] arrayToFind, int startIndex, float tolerance) { if (array != null && arrayToFind != null) { int sourceLength = array.length; int targetLength = arrayToFind.length; int rightIndex = sourceLength - targetLength; if (startIndex < 0) { return -1; } else { if (startIndex > rightIndex) { startIndex = rightIndex; } if (targetLength == 0) { return startIndex; } else { int lastIndex = targetLength - 1; float lastMin = arrayToFind[lastIndex] - tolerance; float lastMax = arrayToFind[lastIndex] + tolerance; int min = targetLength - 1; int i = min + startIndex; while (true) { while (i < min || array[i] >= lastMin && array[i] <= lastMax) { if (i < min) { return -1; } int j = i - 1; int start = j - (targetLength - 1); int var14 = lastIndex - 1; do { if (j <= start) { return start + 1; } } while (Math.abs(array[j--] - arrayToFind[var14--]) <= tolerance); --i; } --i; } } } } else { return -1; } } public static int lastIndexOf(boolean[] array, boolean booleanToFind) { return lastIndexOf(array, booleanToFind, 2147483647); } public static int lastIndexOf(boolean[] array, boolean[] arrayToFind) { return lastIndexOf(array, arrayToFind, 2147483647); } public static int lastIndexOf(boolean[] array, boolean booleanToFind, int startIndex) { if (array == null) { return -1; } else if (startIndex < 0) { return -1; } else { if (startIndex >= array.length) { startIndex = array.length - 1; } for (int i = startIndex; i >= 0; --i) { if (booleanToFind == array[i]) { return i; } } return -1; } } public static int lastIndexOf(boolean[] array, boolean[] arrayToFind, int startIndex) { if (array != null && arrayToFind != null) { int sourceLength = array.length; int targetLength = arrayToFind.length; int rightIndex = sourceLength - targetLength; if (startIndex < 0) { return -1; } else { if (startIndex > rightIndex) { startIndex = rightIndex; } if (targetLength == 0) { return startIndex; } else { int lastIndex = targetLength - 1; boolean last = arrayToFind[lastIndex]; int min = targetLength - 1; int i = min + startIndex; while (true) { while (i < min || array[i] == last) { if (i < min) { return -1; } int j = i - 1; int start = j - (targetLength - 1); int var12 = lastIndex - 1; do { if (j <= start) { return start + 1; } } while (array[j--] == arrayToFind[var12--]); --i; } --i; } } } } else { return -1; } } public static int lastIndexOf(char[] array, char charToFind) { return lastIndexOf(array, charToFind, 2147483647); } public static int lastIndexOf(char[] array, char[] arrayToFind) { return lastIndexOf(array, arrayToFind, 2147483647); } public static int lastIndexOf(char[] array, char charToFind, int startIndex) { if (array == null) { return -1; } else if (startIndex < 0) { return -1; } else { if (startIndex >= array.length) { startIndex = array.length - 1; } for (int i = startIndex; i >= 0; --i) { if (charToFind == array[i]) { return i; } } return -1; } } public static int lastIndexOf(char[] array, char[] arrayToFind, int startIndex) { if (array != null && arrayToFind != null) { int sourceLength = array.length; int targetLength = arrayToFind.length; int rightIndex = sourceLength - targetLength; if (startIndex < 0) { return -1; } else { if (startIndex > rightIndex) { startIndex = rightIndex; } if (targetLength == 0) { return startIndex; } else { int lastIndex = targetLength - 1; char last = arrayToFind[lastIndex]; int min = targetLength - 1; int i = min + startIndex; while (true) { while (i < min || array[i] == last) { if (i < min) { return -1; } int j = i - 1; int start = j - (targetLength - 1); int var12 = lastIndex - 1; do { if (j <= start) { return start + 1; } } while (array[j--] == arrayToFind[var12--]); --i; } --i; } } } } else { return -1; } } }