public class AcademGroup implements Serializable {
Student[] students;
AcademGroup(Student... st) {
this.students = st;
}
What it means "Student... st"? Thank you.
This is the ellipsis operator.
It means you can pass an arbitrary number of arguments to your method/constructor when calling it. E.g.:
new AcademGroup(student1);
new AcademGroup(student1, student2);
new AcademGroup(student1, student2, student3);
etc. In the method/constructor's code it's treated as an array.
It means varargs. Any count of
students you can pass in there.
So you can call it like this
new AcademGroup();
or
new AcademGroup(st);
or
new AcademGroup(st1, st2);
or
new AcademGroup(st1, st2, st3);
and so on, i.e. with 0,1,2,3, etc.
Student objects as parameters.
It means that you can pass any amount of Student
in there and st
will result in an array or a sequence of Student
.