Java : Storing Data in Array Of Object from JOptionPane Dialog

Posted by Bader on Stack Overflow See other posts from Stack Overflow or by Bader
Published on 2010-04-18T15:20:08Z Indexed on 2010/04/18 15:23 UTC
Read the original article Hit count: 406

Filed under:

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 ?

© Stack Overflow or respective owner

Related posts about java