Checking an array list of strings for substring
I need to write a public method that takes an array of strings and checks
to see if there are any strings in the array that contain the substring or
string "nine". I wrote a method to check for "nine" but I'm stumped for
the substring.
public static boolean doesFive ( String [] input ) {
boolean rez = false;
String n = "nine";
for( int i = 0; i < inputArray.length - 1; i++ ) {
if( inputArray[i].equals(n) ) {
rez = true;
}
}
return rez;
}
No comments:
Post a Comment