Java Array Last Index Of lastIndexOfAny(String str, String[] searchStrs)

Here you can find the source of lastIndexOfAny(String str, String[] searchStrs)

Description

last Index Of Any

License

Open Source License

Declaration

public static int lastIndexOfAny(String str, String[] searchStrs) 

Method Source Code

//package com.java2s;

public class Main {

    public static int lastIndexOfAny(String str, String[] searchStrs) {
        if ((str == null) || (searchStrs == null)) {
            return -1;
        }//from w  w  w  . j av  a  2 s  . c  o  m

        int searchStrsLength = searchStrs.length;
        int index = -1;
        int tmp = 0;

        for (int i = 0; i < searchStrsLength; i++) {
            String search = searchStrs[i];

            if (search == null) {
                continue;
            }

            tmp = str.lastIndexOf(search);

            if (tmp > index) {
                index = tmp;
            }
        }

        return index;
    }

    public static int lastIndexOf(String str, char searchChar) {
        if ((str == null) || (str.length() == 0)) {
            return -1;
        }

        return str.lastIndexOf(searchChar);
    }

    public static int lastIndexOf(String str, char searchChar, int startPos) {
        if ((str == null) || (str.length() == 0)) {
            return -1;
        }

        return str.lastIndexOf(searchChar, startPos);
    }

    public static int lastIndexOf(String str, String searchStr) {
        if ((str == null) || (searchStr == null)) {
            return -1;
        }

        return str.lastIndexOf(searchStr);
    }

    public static int lastIndexOf(String str, String searchStr, int startPos) {
        if ((str == null) || (searchStr == null)) {
            return -1;
        }

        return str.lastIndexOf(searchStr, startPos);
    }
}

Related

  1. lastIndexOf(T[] array, T valueToFind, int startIndex)
  2. lastIndexOfAny(byte[] values, byte[] array)
  3. LastIndexOfAny(String str, char[] search)
  4. lastIndexOfAny(String str, char[] searchChars, int startPos)
  5. lastIndexOfAny(String str, char[] targets)
  6. lastIndexOfAny(String str, String[] searchStrs)
  7. lastIndexOfAny(String str, String[] searchStrs)
  8. lastIndexOfAny(String string, char[] anyOf)
  9. lastIndexOfAnyNoCheck(byte[] values, byte[] array, int index, int length)