This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
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: 11256
    
  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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Question about 'public static void main( String args[] ) '