What is difference between :- | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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 Respostas
+ 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