public class ButtonHandler implements ActionListener
{
...
if(button == add)
{
// Problem was here: incrementing num_students too early
// which skips over the array element at index = 0.
// num_students++;
stu[num_students].getData();
num_students++;
}
So the first element in the stu array (at index = 0) was skipped and you were
initializing the second element (index = 1). This caused trouble in the loop
of the
getCopy method:
for(int j = 0; j < stu.length; j++)
{
if(stu[j].getName() == null)
break;
count++;
}
which broke out at the first element (j = 0) because it had been skipped.
So
getCopy returned a zero-length array to the
sortByGPA method.
In conjunction with this you could alter the test method to be able
to add more elements to the array:
private void test()
{
// remove the add.setEnabled line
...
stu[2].addCourse(new Course("ES", 220, 5, "A"));
num_students = 3;
}