I am trying to validate a phone number using Java. How can I ensure that the string is also the correct length (10 digits).
do{
System.out.println("Please provide the phone number starting with area code: ");
this.phone = input.nextLine();
} while (!phone.matches("[0-9]"));