In https://docs.oracle.com/javase/tutorial/java/javaOO/localclasses.html
PhoneNumber(String phoneNumber){
// numberLength = 7;
String currentNumber = phoneNumber.replaceAll(
regularExpression, "");
if (currentNumber.length() == numberLength)
formattedPhoneNumber = currentNumber;
else
formattedPhoneNumber = null;
}
numberLength = 7 => // numberLength = 10
Or, better clarify that the code is being changed that correct numbers only have seven digits (the point of this assignment is to demonstrate effectively final variables.
PhoneNumber(String phoneNumber){
// numberLength = 7;
String currentNumber = phoneNumber.replaceAll(
regularExpression, "");
if (currentNumber.length() == numberLength)
formattedPhoneNumber = currentNumber;
else
formattedPhoneNumber = null;
}
numberLength = 7 => // numberLength = 10
Or, better clarify that the code is being changed that correct numbers only have seven digits (the point of this assignment is to demonstrate effectively final variables.