The following is intended to return the location of the first instance of the String the user enters from the keyboard, -1 if not found.
String names [] = new String[20];
//assume array is initialized
System.out.println(“Enter a name to search for: “);
String lookingFor = scan.nextLine();
int found = -1;
for (int i = 0; i < names.length; i++) {
if ( /* Missing Code */ ) {
found = i;
break;
}
}
Which of the following could replace /* Missing Code* / so that it works as intended?
1. lookingFor.equals(names[i])
2. ! lookingFor.equals(names[i])
3. lookingFor != names[i]
4. lookingFor.equals names)
5. lookingFor [i].equals(names[i])