+ 3

[DUPLICATE] What is the difference between (String... args) and (String[ ] args)?

public static void main (String... args){ System.out.println("hello"); } and public static void main (String [ ] args) { System.out.println("World"); }

14th Apr 2017, 11:22 PM
John Watson
John Watson - avatar
2 Answers
+ 4
i believe they both work the same
14th Apr 2017, 11:22 PM
+ 1
If you re executing your application trough cmd for example your app is called myFirstApp And you type all commands to cmd to execute it .../myFirstApp connect_as_admin Your application saves the string "connect_as_admin" to the args parameter Public static void main(String[] args) { If(args[0].equals("connect_as_admin)) { ... } } Basicly you can set some commands to your application and than manage how your app will work but there is big difference between them because with one "args" you will work as a String field and the second is only String
14th Apr 2017, 11:41 PM
Martin Ďurčo
Martin Ďurčo - avatar