Fórum uso do charAt() #567997
09/04/2009
0

Gfilho
Curtir tópico
+ 0Posts
09/04/2009
João Bier
1 2 3 4 5 6 | boolean achou_arroba, achou_ponto = false; for(int i = 2; i <= txtEmail.getText().trim().length()-1;i++){ if(txtEmail.getText().trim().charAt(i) == '@'){ achou_arroba = true; } } |
Gostei + 0
09/04/2009
Rodrigo_corinthians
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | public class ClasseMain { public static void main(String[] javaFree) { String email = "contato@javafree.com.br"; boolean achouArroba = false, achouPonto = false; if(email != null && email.length() > 0){ for(int i = 0; i < email.length(); i++){ if(email.charAt(i) == '@'){ achouArroba = true; } if(email.charAt(i) == '.'){ achouPonto = true; } } } System.out.println(achouArroba); System.out.println(achouPonto); } } |
Gostei + 0
09/04/2009
Gfilho
Gostei + 0
09/04/2009
Camillo Borges
Gostei + 0
09/04/2009
Gfilho
Gostei + 0
09/04/2009
Junior.esnaola
Gostei + 0
09/04/2009
Gfilho
Gostei + 0
09/04/2009
Camillo Borges
Gostei + 0
09/04/2009
Asdfasdfa
1 2 3 4 | boolean existe = true; if (txtEmail.getText().indexOf("@") == -1) { existe = false; } |
Gostei + 0