we always used to give public static void main(String[] args){} why?
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
0
There's no guarantee that you'll get something that fits an "int" from the command line. Strings, on the other words, can be used for anything you can type on the command line.
hi even you can use public static void main(){}//complies ok instead of public static void main(String[] args){}
but when you try to execute it will result in a runtime exception. The complier expects the main() method to have the following attributes 1 must be public and static,the order in which it is typed is not a error
static public void main(String[] args) {}//ok
2. must return void as return type and have a string[] as argument as of java 5. , you can use main(String...data) instead main(String[] data)
The String[] passed in the main function delas with the command line arguments. so you may overload the main function , but the main function with the above attributes only will be called by the compiler. even if the program may not use the command line arguments but still string[] must be passed as argument.
HTH K Sathya Narayanan
vinayak katkar
Greenhorn
Joined: May 28, 2008
Posts: 2
posted
0
hi arguments given to the main are called as command line arguments when we want to give the file name,string name at the runtime we use the command line argument .
�Knowledge is the food of the soul.�<br /> <br /><br />To get free knowledge,ebook links, free pdf ,and new technology discussions visit the following link <br /><a href="http://vinayakkatkar.blog.co.in" target="_blank" rel="nofollow">http://vinayakkatkar.blog.co.in</a>
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.