Untitled

 avatar
unknown
plain_text
a year ago
393 B
7
Indexable
public class MatchingString
{

    private static String[] arr = {"Hello", "Karel", "CodeHS!", "Karel"};
    
    public static int findString(String myString)
    {
        // your code goes here!
        
        for (int i = 0; i < arr.length; i++)
        {
            if (arr[i].equals(myString))
            {
                return i;
            }
        }
        return -1;
    }
}
Editor is loading...
Leave a Comment