File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes args versus argv Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "args versus argv" Watch "args versus argv" New topic
Author

args versus argv

eddie coberg
Greenhorn

Joined: Oct 22, 2002
Posts: 1
what is the difference between these two? i see both of them being used if my eyes don't deceive me. thank you in advance.
Linda Jones
Ranch Hand

Joined: Aug 17, 2002
Posts: 57
If you mean what is the difference between
public static void main(String[] args)
and
public static void main(String[] argv)
the answer is they are the same. The arg bit is just a made-up name. The convention happens to be to use args or argv (short for arguments I guess) in this situation but it is not required. You could also write
public static void main(String[] eddie)
if you wanted (or anything else).
Linda
[ December 04, 2002: Message edited by: Linda Jones ]
Brian McCallister
Greenhorn

Joined: Dec 03, 2002
Posts: 19
Historically C uses an int named argc to hold the count of comman dline arguments, and an array of char pointers to hold the values.
Args is just clearer if you only use one =)
Greg Charles
Bartender

Joined: Oct 01, 2001
Posts: 1855

argv was the C standard name for the arguments. It stood for "argument vector". The Java standard uses args, which just stands for arguments. In C programs, argv[0] is the name of the program being executed, while in Java, args[0] is just the first command argument. The executable name doesn't exist.
Of course, as was already pointed out, args or argv is just a parameter name. You could call it "fred" and it would still work. Your command parameters would then be accessed by fred[0], fred[1], ...
 
IntelliJ Java IDE
 
subject: args versus argv
 
MyEclipse, The Clear Choice

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture