java - Retrieving using HashMap -


i trying retrieve customer's information main. have class customermanager , class main (which the: main(string[] args))
this code of customermanager class using hashmap collection
public class customermanager {

private static final map<string, customer> customersmanager = new hashmap<> ();    public static void addcustomer(customer c){        // customers     customersmanager.put(c.getid(), c);     customersmanager.put ("id1", new customer ("id1","jonathan", "mifsud", "test address", 21345678, "l001"));     customersmanager.put ("id2", new customer ("id2","david", "aguis", "2nd address", 21456778, "l002"));     customersmanager.put ("id3", new customer ("id3","frank", "mamo", "example address", 21987653, "l003"));   }    public static void findcustomer(customer c){      customersmanager.put(c.getid(), c);   }    public static void deletecustomer(customer c){       customersmanager.remove(c.getid());   } 

}
how can retrieve customer information customermanagement class main. tried this:

system.out.println("insert customer id: ");
customersmanager.findcustomer(c);

giving me error:
variable c might not have been initialized

add following tostring() method in customer class print content:

@override public string tostring() {     return "customer [fname=" + fname          +", lname=" + lname          +", address=" + address          +", phone=" + phone         +", loyaltycard=" + loyaltycard + "]"; } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -