Here you can find the source of getAllOccurences(String str, char guess)
public static List<Integer> getAllOccurences(String str, char guess)
//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; } }