This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
ashish chakkara
Greenhorn
Posts: 10
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
Eclipse IDE Java Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More than that, in Java, you must declare every method parameter types next to the variable name, not outside the method.
 
ashish chakkara
Greenhorn
Posts: 10
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all.........
 
fred rosenberger
lowercase baba
Bartender
Posts: 12180
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and this has nothing to do with main() specifically. you also would not be allowed to do this:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic