Click here to Skip to main content
15,911,132 members
Please Sign up or sign in to vote.
1.40/5 (3 votes)
See more:
I have a confusion that public static void main (String args [] or [] args) l have a doubt that after String which is used first args or [].??

What I have tried:

................................
Posted
Updated 12-Jul-21 23:50pm
Comments
Richard MacCutchan 13-Jul-21 6:37am    
:sigh: another repost. How many times must we tell you to go and learn the language?
Mr.Corona 13-Jul-21 8:08am    
You can use both no problem.
[no name] 13-Jul-21 8:22am    
Thanks a lot. This is the best answer l have got in my this question. Excellent
Richard MacCutchan 13-Jul-21 9:26am    
But the convention in Java is to put the brackets after the class or type name.
public static void main(String[] args)
int[] someNumbers = { 1,2,3,4 };

You should always follow the conventions to avoid confusion. That is why we recommentd you study the language in detail.

1 solution

The answer to this and many more questions can be found in the documentation:
The Java™ Tutorials[^]

For example:
Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)[^]

The [] in this case indicates that the parameter type is an array; it belongs with the parameter type, not the parameter name.
Java
String[] args
 
Share this answer
 
Comments
CPallini 13-Jul-21 6:23am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900