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