This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Main method(String[] ags) what do you use it for?  RSS feed

 
Jay Orsaw
Ranch Hand
Posts: 356
Android Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all! I've been doing Java for awhile, but I've never really needed to use the args String, so I'm curious why would you?


I was reading this http://www.javaranch.com/drive/command.html

when I got into the Q, and they kind of spoke about it... It seems like it has to do with the command line though? Would we do args like that normally?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes - all the time.
 
Phil English
Ranch Hand
Posts: 62
MySQL Database Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jay Orsaw wrote:Hello all! I've been doing Java for awhile, but I've never really needed to use the args String, so I'm curious why would you?


I was reading this http://www.javaranch.com/drive/command.html

when I got into the Q, and they kind of spoke about it... It seems like it has to do with the command line though? Would we do args like that normally?


It is just a way to pass initial parameters to the main method when the program is called from the command line. I guess there might be other instances where you might use it but that's the only one I've used or can think of. What is it that you find odd? That you can only pass in String arrays?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!