Android String Equal findOf(String str, String chars, int startIdx, int endIdx, int offset, boolean isEqual)

Here you can find the source of findOf(String str, String chars, int startIdx, int endIdx, int offset, boolean isEqual)

Description

find Of

License

Open Source License

Declaration

public final static int findOf(String str, String chars, int startIdx,
            int endIdx, int offset, boolean isEqual) 

Method Source Code

//package com.java2s;

public class Main {
    public final static int findOf(String str, String chars, int startIdx,
            int endIdx, int offset, boolean isEqual) {
        if (offset == 0)
            return -1;
        int charCnt = chars.length();
        int idx = startIdx;
        while (true) {
            if (0 < offset) {
                if (endIdx < idx)
                    break;
            } else {
                if (idx < endIdx)
                    break;
            }//from  ww w. ja  v a  2 s .co  m
            char strc = str.charAt(idx);
            int noEqualCnt = 0;
            for (int n = 0; n < charCnt; n++) {
                char charc = chars.charAt(n);
                if (isEqual == true) {
                    if (strc == charc)
                        return idx;
                } else {
                    if (strc != charc)
                        noEqualCnt++;
                    if (noEqualCnt == charCnt)
                        return idx;
                }
            }
            idx += offset;
        }
        return -1;
    }
}

Related

  1. equals(String str1, String str2)
  2. equalsIgnoreCase(String str1, String str2)
  3. equalsIgnoreCase(String string1, String string2)
  4. equals(final String target1, final String target2)
  5. equalsIgnoreCase(final String target1, final String target2)
  6. StringEquals(String s1, String s2)