[Solved] Creating object using user input to store in Java array


Create a class student with variables for each of the fields:

public class Student {
    public String strFirstName;
    public String strLastName; 
    public String strMajor;
    public int intGPA;
    public int intUIN;
    public String strNetID;
    public String strAge;
    public String strGender;

    public static void Student(String strFirstName, String strLastName, String strMajor, int intGPA, int intUIN, String strNetID, String strAge, String strGender) {
        this.strFirstName = strFirstName;
        this.strLastName = strLastName;
        this.strMajor = strMajor;
        this.intGPA = intGPA;
        this.intUIN = intUIN;
        this.strNetID = strNetID;
        this.strAge = strAge;
        this.strGender = strGender;
    }
}

To create a student:

Student mystudent = new Student(firstname, lastname, major, GPA, UIN, netID, age, gender);

To create an array of students:

Student[] myarray = new Student[length];

Adding students to the array:

myarray[0] = new Student(firstname, lastname, major, GPA, UIN, netID, age, gender);

solved Creating object using user input to store in Java array