• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

args versus argv  RSS feed

 
Greenhorn
Posts: 1
  • 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.
 
Ranch Hand
Posts: 57
  • 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 ]
 
Greenhorn
Posts: 19
  • 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 =)
 
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • 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], ...
 
It's a beautiful day in this neighborhood - Fred Rogers. Tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!