0

What is difference between :-

public static void main(String [ ] args) and public static void main(String... args)

14th Dec 2017, 6:53 AM
Prashant Kumar
Prashant Kumar - avatar
2 ответов
+ 13
There is no difference in functionallity in these two. But in respect of conventions use the visibility operators, like public, private, first followed by static. And don't forget the return type! This is how it should look: public static void main (String[] args){} The parameter String[] args is a normal array. String... args are called varargs. In this case there is no difference.  a method that took an arbitrary number of values required you to create an array and put the values into the array prior to invoking the method public static String format(String pattern, Object... arguments);
14th Dec 2017, 7:00 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 2
... is used for variadic parameters. It is just syntactic sugar for T[] where T is the Type.
14th Dec 2017, 7:02 AM
ChaoticDawg
ChaoticDawg - avatar