This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

args versus argv

 
eddie coberg
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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], ...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic