I am new to Java, and I have built a Person class (Code below) with the email as a username. Now, I want to validate or verify that the username used is an email address. How do I validate within the class itself? I am looking for the simplest way possible.
public class Person {
private String email;
private String password;
public Customer(String username, String password) {
this.email = email;
this.password = password;
}
public void setUsername(String email){
this.email = email;
}
public void setPassword(String password){
this.password = password;
}