jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes Question about 'public static void main( String args[] ) ' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question about Watch "Question about New topic
Author

Question about 'public static void main( String args[] ) '

Atrus Greyor
Ranch Hand

Joined: Mar 07, 2004
Posts: 110
what exactly does the "(String args[])" mean???
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11155
    
  16

this is a parameter being passed to the method, just like every other method. in this case, it is an array of string from the command line. if you ran
c:\java myClass input1 input2 input3
you would get an array of strings, called args, with 3 elements in it.
args[0] = "input1"
args[1] = "input2"
args[2] = "input3"
the name of the array, args, is traditional, but you could call it anything.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Nigel Browne
Ranch Hand

Joined: May 15, 2001
Posts: 673

what exactly does the "(String args[])" mean???

It means that an array of String objects can be passed to the method. The array will be entitled "args".
Hth
Nigel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about 'public static void main( String args[] ) '
 
Similar Threads
class 1
Super dumb newbie question...String[] args vs. String args[]
Axis wsdl2java generation duplicate file name issue
How many references
What is the main usage of "String[] args" in public static void main(String[] args)?