I have a little doubt in the following question:
Assuming that the following method will always be called with a phone number in the format ddd-ddd-dddd (where d stands for a digit), what can be inserted at //1 so that it will return a String containing "xxx-xxx-"+dddd, where dddd represents the same four digits in the original number?
Code: Select all
public static String hidePhone(String fullPhoneNumber){
//1 Insert code here }
Code: Select all
return new StringBuilder("xxx-xxx-")+fullPhoneNumber.substring(8);
Because at first I thought that it would throw an exception, because you can't pass an StringBuilder to a method that is asking for a String.