Java : Storing Data in Array Of Object from JOptionPane Dialog
- by Bader
hi guys
i need to know how i can insert data inside objects inside an array of objects using my already made Set methods.
i need to know how should i do it through user , i mean JOptionPane input dialog
[code]
student[] s=new student[5];
for (int i=1 ; i <= s.length ;i++)
{
s[i] = new student(i,"AAA","Ecommerce",0.0);
}
for (int i=1; i<=s.length;i++)
{
name = JOptionPane.showInputDialog("Please Write Name for student n " + i);
major = JOptionPane.showInputDialog("Please Write Major for student n " + i);
gpa =Double.parseDouble(JOptionPane.showInputDialog("Please Write GPA for student n " +i));
s[i]=new student(i,name,major,gpa);
}
[/code]
i tried to do vars here that get data from user by JOptionPane, but it seems that i only use my already made constructor , not the Set methods.
i need to use the methods because it has some validation code inside it.
any ideas ?