Results 1 to 3 of 3
  1. #1
    gopostal703 is offline Member
    Join Date
    May 2012
    Location
    Mumbai
    Posts
    1
    Rep Power
    0

    Default 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!

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default 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".

  3. #3
    k1ng is offline Member
    Join Date
    Apr 2012
    Posts
    59
    Rep Power
    0

    Default 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

  1. use of String[] args
    By mallikanala in forum New To Java
    Replies: 1
    Last Post: 06-21-2011, 08:09 AM
  2. Need Explanation for a Simple Query
    By vinoth in forum JDBC
    Replies: 6
    Last Post: 02-15-2010, 04:01 PM
  3. String, quotes and args
    By mac in forum New To Java
    Replies: 8
    Last Post: 02-04-2010, 04:24 PM
  4. What does String args[] stand for?
    By Addez in forum New To Java
    Replies: 7
    Last Post: 08-19-2009, 10:24 AM
  5. the explanation of output of simple java program
    By amol84 in forum New To Java
    Replies: 1
    Last Post: 11-06-2008, 05:06 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •