Driver code
public static void main ( String [ ] args ) { String S = " barfoothefoobarman " ; ArrayList < String > L = new ArrayList < > ( Arrays . asList ( " foo " , " bar " ) ) ; ArrayList < Integer > indices = findSubstring ( S , L ) ; for ( Integer i : indices ) { System . out . println ( i ) ; } } }