Fórum uso do charAt() #567997
09/04/2009
0
Gfilho
Curtir tópico
+ 0Posts
09/04/2009
João Bier
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
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
boolean existe = true;
if (txtEmail.getText().indexOf("@") == -1) {
existe = false;
}
Gostei + 0