Java String Find getAllOccurences(String str, char guess)

Here you can find the source of getAllOccurences(String str, char guess)

Description

get All Occurences

License

Open Source License

Declaration

public static List<Integer> getAllOccurences(String str, char guess) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<Integer> getAllOccurences(String str, char guess) {
        List<Integer> occs = new ArrayList<>();
        int index = str.indexOf(guess);
        while (index >= 0) {
            occs.add(index);/*from w ww  .java2 s  .  com*/
            index = str.indexOf(guess, index + 1);
        }
        return occs;
    }
}

Related

  1. findAllOccurences(String str, String pattern)
  2. findAllOccurrences(String str, String substr)
  3. findAllSubsequences(String str)
  4. findParam(String src, char patternFrom, char patternTo)
  5. findResourceBundle(String aBundleName, Locale locale)
  6. getOccurenceIndices(String inSubject, String inOccurence)
  7. getSearchTermOccurrences(final String searchTerm, final String content)
  8. indexOfOccurance(String s1, String s2, Integer i)
  9. multiFindBetween(String source, String pre, String post)