File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 61218
    
  66

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: 61218
    
  66

What happened when you tried it?
Richard Tookey
Ranch Hand

Joined: Aug 27, 2012
Posts: 1057
    
  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: 38851
    
  23
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The "args" in (String args[])