I have to accomplish a strange peculiar scenario. Its described as follows:
I have to design a Map where the \'Keys\' are always of String>
Why not make a PhoneNumber wrapper class that exposes an API for soring either one or multipel phone numbers and then can retrieve either one or all (multiple) phone numbers and then make a map of String and PhoneNumber? Something like:
class PhoneNumber {
private String[] phoneNumbers;
public void storePhoneNumber(String... phoneNumbers) {
this.phoneNumbers = phoneNumbers;
}
public String getPhoneNumber() {
if(phoneNumbers.length>=1) {
return phoneNumbers[0];
} else {
return null;
}
}
public List getPhoneNumbers() {
if(phoneNumbers!=null) {
return Arrays.asList(phoneNumbers);
} else {
return null;
}
}
}