Home > Back-end >  Java class object array
Java class object array

Time:09-30

Dear bosses, I through the class object is the purpose of an array to store the contents of the text box, but why I this writing error? Thanks for your advice
 public void actionPerformed (an ActionEvent e) {
int i=0;
Student [] st=new Student [100].
JButton jb=(JButton) um participant etSource ();
If (jb==jbSingUp) {//button to give the corresponding response of the judgment in accordance with

JtfName. SetText (" ");
JPF. SetText (" ");
JtfEmail. SetText (" ");

{} else if (jb==jbReset)
St [I]. Name=jtfName. GetText (). The trim ();//get the user input information
St [I]. Id=JPF. GetText (). The trim ();
St [I]. Grade=Double. ParseDouble (jtfEmail. The getText (). The trim ());
StringBuffer sb=new StringBuffer ();
JtfName. SetText (" ");
JPF. SetText (" ");
JtfEmail. SetText (" ");
Sb. Append (st [I] name + "" + st [I]. [I] id +" "+ st grade +" \ r \ n ");//to the user input file output information
A Boolean flag=saveInfo (sb. ToString ());
If (flag) {
JOptionPane. ShowMessageDialog (null, "entry success");//prompt the user for
i++;
} else {
JOptionPane. ShowMessageDialog (null, "school failure," "I/o error", JOptionPane. ERROR_MESSAGE);
}
}
}

CodePudding user response:

refer to the original poster A991124 response:
, ladies and gentlemen, my purpose is through the class object array to store the contents of the text box, but why I this writing error? Thanks for your advice


Student [] st=new Student [100]. Here only initializes the Student arrays, array of each class also needs to initialize the

Additional st [I]=new Student ();

Otherwise, you must be an error,

CodePudding user response:

reference 1st floor qq_39936465 response:
Quote: refer to the original poster A991124 response:

Dear bosses, I through the class object is the purpose of an array to store the contents of the text box, but why I this writing error? Thanks for your advice


Student [] st=new Student [100]. Here only initializes the Student arrays, array of each class also needs to initialize the

Additional st [I]=new Student ();

Otherwise you must be an error,

Eldest brother, still I can't

CodePudding user response:

refer to the second floor A991124 response:
eldest brother, still I can't


Do not want to see you how to write the student class structure, the student class post
  • Related