wood burning stoves*
The moose likes Java in General and the fly likes The Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "The "args" in (String args[])" Watch "The "args" in (String args[])" New topic
Author

The "args" in (String args[])

Mukul Anand
Greenhorn

Joined: Nov 28, 2012
Posts: 29
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

Joined: Jan 10, 2002
Posts: 60810
    
  65

The name is a convention rather than a language rule. But sometimes, following convention is as important as following the language rules.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mukul Anand
Greenhorn

Joined: Nov 28, 2012
Posts: 29
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

Joined: Jan 10, 2002
Posts: 60810
    
  65

What happened when you tried it?
Richard Tookey
Ranch Hand

Joined: Aug 27, 2012
Posts: 1035
    
  10

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

Joined: Nov 28, 2012
Posts: 29
okay.. Thanks everybody
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
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

Joined: Nov 28, 2012
Posts: 29
Hmm.. Got it
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: The "args" in (String args[])
 
Similar Threads
main(String[]args)
Can you guys please explain me this
valid syntax
simple main function doubt
try again