3
I am doing a simple test to check if the user has typed a valid email. So I have an error of syntax in token "@" invalid Assignmentperator.
Code of the main class:
public class Email {
static String email = "[email protected]";
public static void main(String[] args) {
}
public static void validarEmail(){
//Verifica a posicao do @ no emal.
int validarEmail = email.indexOf("@");
//System.out.println(validarEmail);
}
public static void obterNome(){
//Seleciona o que esta escrito antes do @.
String obterNome = email.substring(0, 6);
//System.out.println(obterNome);
}
Class that checks the Email:
public class VerificaEmail {
public static void main(String[] args) {
Email e = new Email();
//Verifica se o Email e valido.
boolean b = e.validarEmail([email protected]);
if(!b)
System.out.println("Email Inválido");
else
System.out.println("Email Válido");
// Imprime o que esta antes do @.
String nome = e.obterNome([email protected]);
System.out.println(nome);
}
If I put in String and the email in quotes does not work tbm.
– Itallo Freire
But the error when email (in the two calls inside
VerificaEmail
) is in quotes is different, right?– user25930
if I place the class emails
verificaEmail
quotation marks it shows the following error - test cannot be resolved to a variable - Syntax error on token "@", invalid Assignmentperator - pessoa cannot be resolved to a variable - The method validarEmail() in the type Email is not applicable for the Arguments (String) And them and the same email from the main class.– Itallo Freire
"person cannot be resolved to a variable" this error is precisely pq you are passing without the quotation marks, should be
boolean b = e.validarEmail("[email protected]");
– Math
@Math I’ve tried to do it this way with the most error quotes tbm
– Itallo Freire
But at least it must be another mistake, it’s not?
– Math
@re22 In fact, the way he put it worked but I ended up discovering what was causing the error. And I used other methods to solve the problem. But remembering that the way he put tbm works only that it is more complex and mine became easier.
– Itallo Freire