0

public static void main(String args[])

0 I have noticed in Java some variation of the beginning code. In some places I see: public static void main(String args[]) In other places I see: public static void main(String[] args) What is the difference between one and the other?

1st Jun 2018, 1:05 AM
Michelle
Michelle - avatar
2 odpowiedzi
+ 1
both are correct, but square brackets after the data type is preferred. I guess it increases readability.
1st Jun 2018, 1:36 AM
Eterxoz
Eterxoz - avatar
+ 4
Java supports the syntax of square brackets being written after the array identifier as a legacy syntax from C, for C programmers to better adapt to Java when porting over. The latter (square brackets after type) is preferred in Java.
1st Jun 2018, 3:20 AM
Hatsy Rei
Hatsy Rei - avatar