A function parameter that can match zero or more arguments from the caller. Scala also supports
vararg parameters, so you can define a function with a variable number of input arguments.
Java
All var args in the methods will be converted in to an Array internally. If we pass an array to var args method, values of array will be considered as a var args instead of the array input.Java Example
Scala
All var args in the Scala method are converted into a seq internally. If we pass a seq to var args method this is passed as one of the var arg instead of passing its values as a var args. This behavior differs from Java in the Scala. To pass var args in any method in the Scala we need to use a special way variableName: : _*
Scala Example
Post a Comment
Post a Comment