public static void emailChecker() {
Scanner input = new Scanner(System.in);
String email = " ";
char[] test;
int counter = 0;
System.out.println("Please enter your email: ");
email = input.nextLine();
test = email.toCharArray();
for (int i = 0; i < email.length(); i++) {
if (test[i] == 64 || test[i] == 46) {
System.out.println("Email is valid");
} else {
System.out.println("Email is not valid");
}
}
}
I figured out that on line 10 the output will say email is valid if the string contains either a "." or a "@". But I want my code to only say that the string is valid when the "." comes after the "@". A sample of a valid email is: email@email.com.