Trying to convert program from array to array list java -


i have 2 classes. @ moment, can save 99 entries .txt file. want expand upon this. if following examgradesgui arraylist rather array:

    string[] firstname = new string[99];     string[] lastname = new string[99];     string[] subjectunit = new string[99];     double[] exammark = new double[99]; 

i managed start off declaring array below (for firstname):

arraylist<string> firstname = new arraylist<string>(); 

then, not sure how make work , set methods still in array form. if appreciate it. thanks

maybe should more oop have :

list<student> students = new arraylist<student>();  class student{     private string firstname;     private string lastname;     private string subjectunit;     private double exammark ;     // generate getters , setters , constructor 

}

// code create new student in gettext():   student newstudent = new student (         firstnametxt.gettext() ,        lastnametxt.gettext(),      subjectunittxt.getitemat(subjectunittxt.getselectedindex()),      double.parsedouble(exammarktxt.gettext()) );  // add newstudent list students.add( newstudent ); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -