import java.util.*;
import java.lang.*;
import java.io.*;
class Ideone {
static String[] listaUsuarios
= new String[] { "1",
"12",
"123" }; System.
out.
println(autentica
("123")); System.
out.
println(autentica
("456")); }
public static boolean autentica
(String usuario
) { for(int i = 0; i < listaUsuarios.length; i++) {
if(usuario.equals(listaUsuarios[i])) {
return true;
}
}
//opcionalmente faz alguma coisa aqui.
return false;
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpjbGFzcyBJZGVvbmUgewoJc3RhdGljIFN0cmluZ1tdIGxpc3RhVXN1YXJpb3MgPSBuZXcgU3RyaW5nW10geyAiMSIsICIxMiIsICIxMjMiIH07CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykgdGhyb3dzIGphdmEubGFuZy5FeGNlcHRpb24gewoJCVN5c3RlbS5vdXQucHJpbnRsbihhdXRlbnRpY2EoIjEyMyIpKTsKCQlTeXN0ZW0ub3V0LnByaW50bG4oYXV0ZW50aWNhKCI0NTYiKSk7Cgl9CglwdWJsaWMgc3RhdGljIGJvb2xlYW4gYXV0ZW50aWNhIChTdHJpbmcgdXN1YXJpbykgewoJICAgIGZvcihpbnQgaSA9IDA7IGkgPCBsaXN0YVVzdWFyaW9zLmxlbmd0aDsgaSsrKSB7CiAgICAJICAgIGlmKHVzdWFyaW8uZXF1YWxzKGxpc3RhVXN1YXJpb3NbaV0pKSB7CiAgICAgICAgCSAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAJfQogICAgCX0KICAgIAkvL29wY2lvbmFsbWVudGUgZmF6IGFsZ3VtYSBjb2lzYSBhcXVpLgogICAgCXJldHVybiBmYWxzZTsKCX0KfQ==