2014-12-23 45 views
-2

如何在阵列列表中添加对象的内容?如何保存阵列列表中的对象内容?

感谢,

这是我的代码

ArrayList soft1=new ArrayList(); 



    if ("Software".equals((String)major.getSelectedItem())){ 

     add(p2s,BorderLayout.CENTER); 
     p2s.setVisible(true); 
     p2n.setVisible(false); 
     p2sc.setVisible(false); 
     if (e.getSource()==save){ 
      String id1=id.getText(); 
      String name1=name.getText(); 
      String gender11=(String)gender1.getSelectedItem(); 
      String major1=(String)major.getSelectedItem(); 

      StudentSoftware software=new StudentSoftware(studentID, studentName, gender, studentMajor, course1, course2, course3, mark1, mark2, mark3); 
+0

请清除问题? –

回答

1

需要声明与POJO类ArrayList中为ArrayList<StudentSoftware> soft = new ArrayList<StudentSoftWare>()。然后在生成POJOclass中的setter和getter之前,初始化StudentSoftware为StudentSoftware student = new StudentSoftware() POJOClass的设置值为student .setid(id)。最后,将POJOclass对象添加到Arraylist中作为soft.add(student)

我认为它对U有用....

+0

非常感谢,我会尽力去做。 – safia

+0

K.试试看Safia –

+0

对不起,先生,我还有其他问题。 – safia