I have an ArrayList and add strings that I'm checking for to it like this.
ArrayList<String> al = new ArrayList<String>();
al.add("is");
al.add("the");
Then I have a method that returns a match found in the String that is also in the ArrayList.
public static String getWord(String str1, ArrayList<String> list)
{
for(int i = 0; i < list.size(); i++)
{
if(str1.toLowerCase().contains(list.get(i)))
{
return list.get(i);
}
}
return false;
}
Although when I want to check a String that has more than one match it only returns the fist one that was added into the ArrayList, so
al.add("is");
al.add("the");
it would return "is"
If I add them like this
al.add("the");
al.add("is");
it would return "the"
I need a way of determining how many matches there are and returning them individually.