简体   繁体   中英

In which situations we can use public static void main(String… args) instead of public static void main(String[] args)

在哪些情况下我们可以使用public static void main(String... args)而不是public static void main(String[] args)

In all situations where we have Java 1.5 or greater. Prior to Java 1.5, there were no varargs so you could not use String...

... is just syntactic sugaring over an array declaration. You can always use public static void main(String... args) , assuming you're using at least Java 5.0 (which introduced the ... operator).

For Java 1.5 and above, you can use any of this two. In case of ... argument array is not necessarily of String type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM