As you know that main is the method having array of Strings "args" as parameter to this method. the parameters to any method are not instantiated but their values are passed from the place where they are called.
When you pass the values from command line, these values are handled as a new array of values and passed to the args parameter of main method by the java interpreter. On Thu, Jun 25, 2009 at 8:57 AM, javanew2 <[email protected]> wrote: > > Hi all, > > In week 3's "Command-line Arguments" presentation the "args" array is > discussed and the code below is used in an example. > > Week 3's "Java Arrays" lesson discussed the process of declaring an > array and then instantiating an array. In this command line arguments > lesson there is no mention of instantiation of the "args" array. > What is the explanation for not having to instantiate this "args" > array? > Is this special instance of an array not need to be instantiated or is > Java just "handling" this in the background? > > Thanks > > > ***************************** > ***************************** > ***************************** > To print the array of arguments, we write: > public class CommandLineSample > { > public static void main( String[] args ){ > > for(int i=0; i<args.length; i++){ > System.out.println( args[i] ); > } > } > } > ***************************** > ***************************** > ***************************** > > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
