For instance, let's say I have the following array of app names:
{"Math Workshop", "Math Place", "Mathematics", "Angry Birds"}
I want to scan this array for any elements that contains the word math. How can I do that?
For instance, let's say I have the following array of app names:
{"Math Workshop", "Math Place", "Mathematics", "Angry Birds"}
I want to scan this array for any elements that contains the word math. How can I do that?
 
    
     
    
    Try the following code:
String[] appNames = {"Math Workshop", "Math Place", "Mathematics", 
    "Angry Birds"};
for (String name: appNames) {
  if (name.toLowerCase().contains("math")) {
    // TADA!!!
  }
}
Since contains() is case-sensitive, you will need to convert your string to lower case if you want a case-insensitive match.
 
    
    for (String title : array) {
    if (title.toLowerCase().indexOf("math") != -1). {
        return true;
    } 
}
return false;
