Hey!
Did you try using the String1.compareTo(String2) while using for loop to check all the occurences.
Hope this helps
Cheers