public void setMobile(String mobile) {
char[] mobileList = mobile.toCharArray();
boolean isValid = true;
for(char x : mobileList)
{
if(!Character.isDigit(x))
{
isValid = false;
}
}
if(isValid)
{
this.mobile = mobile;
}
}
Is this the best way of doing things? Cheers.