Menggunakan untuk setiap loop untuk mencari di array
import java.util.Scanner;
public class Sample {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String names[] = { "Jasmine", "Lyka", "Marbie", "Soleen", "Tiny" };
System.out.print("Enter name to search:");
String search = input.nextLine();
for (String name : names) {
if (name.equalsIgnoreCase(search)) {
System.out.println("We found " + name);
break;
} else {
System.out.println(name);
}
}
input.close();
}
}
Fernandez, Jasmine M.