class Student { private int testGrade; // instance variable (non-static) private static int numStudents = 0; // static variable (class variable) private final static int pointsPossible = 100; // class constant public Student() { testGrade = 0; } public void setGrade(int gr) { testGrade = gr; } public int getGrade() { return testGrade; } public static void incrementNumStudents() { numStudents++; } public static int getNumStudents() { return numStudents; } }In this sample code:
public Date(int m, int d, int y) // constructor with 3 params { month = m; day = d; year = y; } public Date(int m, int d) // constructor with 2 params { this(m, d, 0); // calls constructor with 3 params }
Student[] list = new Student[10];This only creates an array of reference variables -- references for type Student
list[0] = new Student(); list[1] = new Student();but it's easier with a loop (as long as you are using the same constructor for each object):
for (int i = 0; i < list.length; i++) list[i] = new Student();Each list[i] is the reference to an object now.