Starting a Java program with no arguments (as discussed in the thread before) results in new String for args, hence args is a valid Array, the loop does have nothing to iterate over, and also has no reason to throw Exceptions.
JDBCSupport - An easy to use, light-weight JDBC framework -
Joined: Jun 30, 2009
Sebastian Janisch wrote:the loop does have nothing to iterate over, and also has no reason to throw Exceptions.
sreekanth kulkarni wrote:Could not understand how " for (String s:args) " would be read...
is it similar to assigning value to variable s i,e s=args;
if so where is size declaration for args... this seems to be silly but just wanted to understand the syntax: for (String s:args)
I'm not quite sure what you're having trouble with. The construct is called a "for-each" loop, and was introduced in version 5 for doing precisely what you see without the need for indexes.
As to size declarations: why would you need one? The array (args) already has a size.
Perhaps you could elaborate on exactly what it is you don't understand.
Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here