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

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -