0

[DUPLICATE] public static void main (String args[])  , public static void main (String[] args) . ....Which one is correct..?

23rd Dec 2016, 4:19 AM
Saurabh Pandey
Saurabh Pandey - avatar
7 Answers
+ 6
The square brackets belong on String[]. In all honesty, you don't need to use String[] args for most projects you'll be coding. You can safely remove it.
23rd Dec 2016, 4:30 AM
Tamra
Tamra - avatar
+ 6
You're welcome! ^_^ Always good to ask, when you're just starting off.
23rd Dec 2016, 4:53 AM
Tamra
Tamra - avatar
+ 5
Oh, whoops, didn't know that. :/ I'm not too familiar with Java yet...
25th Dec 2016, 8:32 AM
Tamra
Tamra - avatar
+ 3
first at all everything depends in which language you are working, and as the another partner seid before, you can delete that with no problems, and anything gonna happen, but you could use it to set some argument since the begining of the compiling for example: public static void Main(string[] args ){ for(int k=0; k<args.Leght; k++){ Console.WriteLine(arg[k]); } } /*as you can see if you set since the begining of the compilation some dates, you will get some things seted before, remenber how a program works*/
23rd Dec 2016, 4:53 AM
michael ventura
michael ventura - avatar
+ 1
@michael, you are right, if he were using C#, and @Tamra, String[] args cannot be removed, because main() is never called, but main(String[] args) is called directly from the JVM
25th Dec 2016, 5:10 AM
Gabe Rust
Gabe Rust - avatar
0
im beginner that why it's creating problem thank u so much for ur valuable suggestion
23rd Dec 2016, 4:37 AM
Saurabh Pandey
Saurabh Pandey - avatar
0
Number 2!
27th Dec 2016, 3:53 PM
Tuuba