• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Atrus Greyor
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what exactly does the "(String args[])" mean???
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12098
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nigel Browne
Ranch Hand
Posts: 703
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic