0
public class AcademGroup implements Serializable {
Student[] students;

AcademGroup(Student... st) {
    this.students = st;
}

What it means "Student... st"? Thank you.

Eluvium
  • 163
  • 1
  • 4
  • 17

3 Answers3

3

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.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
2

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.

peter.petrov
  • 38,363
  • 16
  • 94
  • 159
1

It means that you can pass any amount of Student in there and st will result in an array or a sequence of Student.

Octoshape
  • 1,131
  • 8
  • 26