hey Guys,
im creating a clas that is to be used in a HashMap to map phone numbers to name.
for example : map.put( new PhoneNumber(207, 8269600, 260), “Paul”);
public final class PhoneNumber {
private final int areaCode;
private final int number;
private final int extension;
public PhoneNumber(int areaCode, int number, int extension){
this.areaCode = areaCode;
this.number = number;
this.extension = extension;
}
public int getAreaCode(){
return areaCode;
}
public int getNumber(){
return number;
}
public int getExtension(){
return extension;
}
}
what i need is that when i later want to retrieve the corresponding name like :
map.get(new PhoneNumber(207, 8269600, 260));
it should return the String “Paul”.
What i need is a methods that would enable the name to be correctly and efficiently retrieved from the map when a newly constructed PhoneNumber object is used?
please help i need this urgently and i have no experience with hash maps and not enough time to learn them
any help will hep
thank you