fork download
  1. class Program {
  2. static String[] listaUsuarios = new String[] { "1", "12", "123" };
  3. public static void main (String[] args) throws java.lang.Exception {
  4. System.out.println(autentica("123"));
  5. System.out.println(autentica("456"));
  6. }
  7. public static boolean autentica (String usuario) {
  8. for(int i = 0; i < listaUsuarios.length; i++) {
  9. if(usuario.equals(listaUsuarios[i])) {
  10. return true;
  11. }
  12. }
  13. //opcionalmente faz alguma coisa aqui.
  14. return false;
  15. }
  16. }
  17.  
  18. //https://pt.stackoverflow.com/q/48512/101
Success #stdin #stdout 0.05s 2184192KB
stdin
Standard input is empty
stdout
true
false