Java Language Varargs (Variable Argument)

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!


A “varargs” method argument allows callers of that method to specify multiple arguments of the designated type, each as a separate argument. It is specified in the method declaration by three ASCII periods (...) after the base type.

The method itself receives those arguments as a single array, whose element type is the type of the varargs argument. The array is created automatically (though callers are still permitted to pass an explicit array instead of passing multiple values as separate method arguments).

Rules for varargs:

  1. Varargs must be the last argument.
  2. There can be only one Varargs in the method.

You must follow above rules otherwise program will give compile error.

Got any Java Language Question?