suppose i've an arraylist (arr1) with the following values:
"string1 is present"
"string2 is present"
"string3 is present"
"string4 is present"
i wanted to see if the substring 'string2' is present in this arraylist. by looping through the arraylist and using 'get' by index i extracted element at each index and then using 'contains' method for 'Strings' i'm searched for 'string2' and found a match
for (int i=0;i<arr1.size(); i++)
{
String s1=arr1.get(i);
if (s1.contains("string2"))
{
System.out.println("Match found");
}
}
is there a way to use the 'contains' method of the arraylist itself and do the same instead of me looping through the arraylist and using the 'contains' method for 'String' to achieve this. Can someone please let me know.
Thanks