aspose file tools*
The moose likes Beginning Java and the fly likes  main(args)  instead of  main(String[] args) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark " main(args)  instead of  main(String[] args) " Watch " main(args)  instead of  main(String[] args) " New topic
Author

main(args) instead of main(String[] args)

ashish chakkara
Greenhorn

Joined: Sep 13, 2012
Posts: 10

HI all,

Can anybody help me in explainig the reason for the error while compiling the following java code.




Thanks & Regards
Ashish

nir sharma
Ranch Hand

Joined: Sep 11, 2012
Posts: 72

Hi,
When the Java interpreter executes an application it starts by calling the class's main method. The main method then calls all the other methods required to run your application. So when you compile this, compiler doesn't know what 'args' that you have mentioned as an argument to main method.

Use code tag for code.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

More than that, in Java, you must declare every method parameter types next to the variable name, not outside the method.


[My Blog]
All roads lead to JavaRanch
ashish chakkara
Greenhorn

Joined: Sep 13, 2012
Posts: 10

Thank you all.........
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11314
    
  16

and this has nothing to do with main() specifically. you also would not be allowed to do this:



There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: main(args) instead of main(String[] args)