fork download
  1. import java.util.*;
  2.  
  3. class Main {
  4. public static void main (String[] args) {
  5. ArrayList<String> posicoes = new ArrayList<String>();
  6. posicoes.add("Ricardo;01051509912;gmail");
  7. posicoes.add("Renato;123456789123;hotmail");
  8. posicoes.add("Rodrigo;09873923121;yahoo");
  9. System.out.println(BuscaString(posicoes, "01051509912"));
  10. System.out.println(BuscaString(posicoes, "123456789123"));
  11. }
  12. public static int BuscaString(ArrayList<String> lista, String busca) {
  13. for (int i = 0; i < lista.size(); i++) if (lista.get(i).contains(busca)) return i;
  14. return -1;
  15. }
  16. }
  17.  
  18. //https://pt.stackoverflow.com/q/233378/101
Success #stdin #stdout 0.06s 32364KB
stdin
Standard input is empty
stdout
0
1