It is necessary to use generics with ArrayList
? Like this:
ArrayList<Object> software=new ArrayList<Object>();
Can I write it without it? Because I face a problem when I want to add object to it.
What I try to do is to get info from the frame and then create object and add it to tha arraylist
class Listener implements ActionListener {
public void actionPerformed(ActionEvent e) {
ArrayList software= new ArrayList();
String s = (String) major.getSelectedItem();
if((e.getActionCommand()).equals("SAVE")){
int st_id=Integer.parseInt(id.getText());
String st_name=name.getText();
String st_gender = (String) gender.getSelectedItem();
String st_major = (String) major.getSelectedItem();
String code1=code_sw1.getText();
String code2=code_sw2.getText();
String code3=code_sw3.getText();
double mark1=Double.parseDouble(m_sw1.getText());
double mark2=Double.parseDouble(m_sw2.getText());
double mark3=Double.parseDouble(m_sw3.getText());
St_Sw ob1=new St_Sw(st_id,st_name,st_gender,st_major,code1,code2,code3,mark1,mark2,mark3);
software.add(ob1);
}
}
}