Prime Checker

  • + 1 comment

    It is basically called varargs or variable length arguments in java. The argument is specified with 3 periods(...) after the type. This syntax tells the compiler that the method can be called with 0 or more arguments. One thing to note here is that your method cannot have 2 varargs as arguments and varargs must always be last in method with more than 1 arguments. For example , void method(int... n1,int... n2) is invalid. void method(int... n1,int n2) is invalid, but void method(int n1,int... n2) is valid. It is logical since the compiler knows how many arguments to assign to varargs, thats why it should always be written last in the argument list