/**
* Set the person's mobile phone number
*/
public void setMobile(String mobile) {
for (int i = 0; i < mobile.length(); i++) {
if (!Character.isDigit(mobile.charAt(i))) {}
}
this.mobile = mobile;
}
So I basically need to make sure the string only contains digits, and if it contains non-digits for the method just to do nothing. The problem I have is that if there is a random character in a string of numbers i.e. "034343a45645" it will still set the method. Any help is appreciated thanks!