Here I am again with more questions. I am groveling for help.
I am working on a program in Netbeans 5.5.1 where I created a class called Student that gets and sets Last Name, First Name and Student ID. Now the program to run as a samle of this class will store the first Student I get and put it into slot [0] of my array and then I increment my NumStudents, as a count to moveon to the next array slot. The problem is that it only puts the Student info into slot[0], even on the 2nd or 3rd entry to store information. I'm not sure if the problem is in the gets and sets in my class or in my Store Info button listener.
Here is a bit of the code. I have comments to help explain my problem.
Thank you oh virtuosos of Java! This stuff brings me to tears!
Expand|Select|Wrap|Line Numbers
- private void mouseclickedbtnStoreInfo(java.awt.event.MouseEvent evt)
- {
- // Code to store info from the textbox entered by user:
- s.setFirstName(txtFirstName.getText());
- s.setLastName(txtLastName.getText());
- s.setStudentID(txtStudentID.getText());
- arrayAllStudents[NumStu] = s;
- NumStu++;
- txtFirstName.setText("");
- txtLastName.setText("");
- txtStudentID.setText("");
- //Testing array storage here also
- /*This only prints out only for the second student entered, loses the first, NumStu times, apparently only storing in slot 0. array is of Student class as is the variable s.*/
- for(int i=0;i<NumStu;i++){
- System.out.println(arrayAllStudents[i].getStudentID());
- System.out.println(arrayAllStudents[i].getFirstName());
- System.out.println(arrayAllStudents[i].getLastName());
- }
- }