• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The "args" in (String args[])

 
Mukul Anand
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just wanted to know whether it is just a convention to write 'args' in (String args[]) and we could take the liberty of replacing it with any other array name.
Because, even if we change it, the compiler doesn't give a damn !!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65129
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The name is a convention rather than a language rule. But sometimes, following convention is as important as following the language rules.
 
Mukul Anand
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Agreed. But whether violating this particular convention could ever make the program behave abnormally in any case?
Is it that the JVM is "hardwired" to take only 'args' as the name, and won't recognize the argument if we do change it to something else??
Just to make sure.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65129
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happened when you tried it?
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mukul Anand wrote:
Is it that the JVM is "hardwired" to take only 'args' as the name, and won't recognize the argument if we do change it to something else?


It is not hard wired and you can use any legal Java identifier.
 
Mukul Anand
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay.. Thanks everybody
 
Campbell Ritchie
Sheriff
Pie
Posts: 49865
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Older books used this method heading:-
public static void main(String arguments[])
That is poor style because the [] are part of the type and should therefore precede the identifier.
 
Mukul Anand
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm.. Got it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic