java - can't added my object to to ArrayList -


i tried add object arraylist ? ican't whyyyyyy ?

arraylist<patient> emer;   patient p = new patient();   p.setname(jtextfield1.gettext()); p.setsurname(jtextfield2.gettext()); p.setgender(jradiobutton1.gettext()); } p.setbooldtype(jcombobox1.getselecteditem() + ""); p.setentarnceday(jcombobox2.getselecteditem() + "/" + jcombobox3.getselecteditem() + "/" + jcombobox4.getselecteditem()); p.setfee(integer.parseint(jtextfield8.gettext()));  emer.add(p); 

you haven't initialized emer , getting "local variable not initialized" error.

arraylist<patient> emer; 

what need initialize emer new array list instance.

arraylist<patient> emer = new arraylist<patient>(); 

or better yet:

list<patient> emer = new arraylist<patient>(); 

Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -