Code Magnets in Head First Java, page 351: The following code (Exercise solution straight from the book) compiles, but when I run it, I get the above exception on main because of the statement " Stringtest = args;"
When I comment out that statement and uncomment my own statement just below that (String test = "no";) , I get no runtime error.
Please would someone explain what the statement, String test = args; means, and why I get a runtime error. thanks in advance.
The String array in main contains the arguments you supply at runtime. If you do not supply any arguments, then this array will have a length of zero, and trying to access its elements will result in an exception.
To supply arguments at runtime, enter them on the command line after the class name. For example...
java ShowMyArgs here are some args [ December 05, 2008: Message edited by: marc weber ]
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org