This is my validation for user ID number, when testing, I entered an invalid string with a length less than 10 and it sets the input and doesn't execute the else statement.
The Source Code:
private String phoneNum;
public personalInfo(String phNum) {
setPhoneNum(phNum);
}
public String getPhoneNum() {
return phoneNum;
}
public void setPhoneNum(String phNum) {
if (phoneNum.startsWith("05")&&(phoneNum.length()==10)){
phoneNum = phNum;
}
else throw new IllegalArgumentException ("Invalid Phone Number!");
}