Java Utililty Methods Array Last Index Of

List of utility methods to do Array Last Index Of

Description

The list of methods to do Array Last Index Of are organized into topic(s).

Method

intlastIndexOf(byte[] source, byte[] match)
Returns the index in the source array where the last occurrence of the specified byte pattern is found
if (source.length < match.length) {
    return -1;
for (int i = (source.length - match.length); i >= 0; i--) {
    if (startsWith(source, i, match)) {
        return i;
return -1;
intlastIndexOf(char[] toBeFound, char[] array)
last Index Of
return lastIndexOf(toBeFound, array, 0);
intlastIndexOf(char[] toBeFound, char[] array)
last Index Of
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;
intlastIndexOf(final byte[] reference, final byte[] query)
Find the last occurrence of the query sequence in the reference sequence Returns the index of the last occurrence or -1 if the query sequence is not found
int queryLength = query.length;
for (int r = reference.length - queryLength; r >= 0; r--) {
    int q = 0;
    while (q < queryLength && reference[r + q] == query[q]) {
        q++;
    if (q == queryLength) {
        return r;
...
intlastIndexOf(final byte[] str, int startIndex, int endIndex, final byte ch)
last Index Of
if (startIndex < 0) {
    startIndex = 0;
if (endIndex > str.length) {
    endIndex = str.length;
for (int i = endIndex - 1; i >= startIndex; --i) {
    if (str[i] == ch) {
...
intlastIndexOf(final char[] source, final int start, final int end, final char ch)
last Index Of
assert source != null;
for (int i = end - 1; i >= start; i--) {
    if (equalsIgnoreCase(source[i], ch)) {
        return i;
return -1;
intlastIndexOf(final Object[] array, final Object objectToFind)

Find the last index of the given object within the array.

return lastIndexOf(array, objectToFind, Integer.MAX_VALUE);
intlastIndexOf(int[] array, int intToFind)
last Index Of
return lastIndexOf(array, intToFind, 2147483647);
intlastIndexOf(int[] array, int valueToFind)
last Index Of
int startIndex = array.length - 1;
for (int i = startIndex; i >= 0; i--) {
    if (valueToFind == array[i]) {
        return i;
return INDEX_NOT_FOUND;
intlastIndexOf(Object o, Object[] vals)
LAST INDEX OF
return lastIndexOf(o, vals, 0);