Results 1 to 3 of 3
- 05-20-2012, 08:27 AM #1
Member
- Join Date
- May 2012
- Location
- Mumbai
- Posts
- 1
- Rep Power
- 0
Simple explanation of (string[ ] args) wanted
Hey guys, I have been doing java for some time now( though not for that long ) and I see that after public static void main, I always add (string[ ] args) because all books include it and everywhere I go I see it. Is it for providing an argument to the main method or what? Please explain to me in terms 14 year old would understand:). I'm learning Java because you can do so much with it and I want to take up jobs on elance and earn some money.( I just got an ipad 3 with money I earned from mturk) Thanks in advance!
- 05-20-2012, 09:14 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
Re: Simple explanation of (string[ ] args) wanted
Have a read of A Closer Look at the "Hello World!" Application in Oracle's Tutorial - especially the section headed "The main Method".
- 05-21-2012, 12:16 PM #3
Member
- Join Date
- Apr 2012
- Posts
- 59
- Rep Power
- 0
Re: Simple explanation of (string[ ] args) wanted
Have you tried writing Java code in a text file and compiling it using the command line 'javac' command then running with the 'java' command? it looks like this...
java MyJavaClass
if you have then if you do this instead
java MyJavaClass argument1 argument2 argument3
everything after your classname 'MyJavaClass' gets passed into your Java program through the 'String[] args' so that in your Java program
args[0] will be equal to 'argument1'
args[1] will be equal to 'argument2'
args[2] will be equal to 'argument3'
...does that make sense?
Similar Threads
-
use of String[] args
By mallikanala in forum New To JavaReplies: 1Last Post: 06-21-2011, 08:09 AM -
Need Explanation for a Simple Query
By vinoth in forum JDBCReplies: 6Last Post: 02-15-2010, 04:01 PM -
String, quotes and args
By mac in forum New To JavaReplies: 8Last Post: 02-04-2010, 04:24 PM -
What does String args[] stand for?
By Addez in forum New To JavaReplies: 7Last Post: 08-19-2009, 10:24 AM -
the explanation of output of simple java program
By amol84 in forum New To JavaReplies: 1Last Post: 11-06-2008, 05:06 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks