i am new to this data structure. i have not been able to get the entered value for the key from a HashMap.
public class Patient {
public String name,insurance;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getInsurance() {
return insurance;
}
public void setInsurance(String insurance) {
this.insurance = insurance;
}
I have a class administrator with HashMap that takes string as key and Object Patient as value. Enter values of name and insurance and put it in the HashMap.
public class Administrator{
public Administrator() {
}
HashMap <String,Patient> hashMap = new HashMap <String,Patient>();
static Patient patient = new Patient();
public void PatientInfo(){
String patientName = 'User input'
String insurance = 'User input'
patient.setName(patientName);
patient.setInsurance(insurance);
hashMap.put(patient.getName(),patient);
}
}
(i enter value jay,aetna and rod,Metroplus)
Another class called PatientList that will list out the list of name and insurance entered.
public class PatientList{
public PatientList(){}
public static table(Map<String,Patient>map){
for (Map.Entry<String, Patient>entry : map.entrySet()){
System.Out.println(entry.getKey(),entry.getValue().getInsurance());
///It prints jay aetna,rod aetna
///It prints same value for both different key.
{
}