Yes Arul , this is new in 1.5 .
I am slightly modifying your code like this
so that it doesn't compile:
what is happening here is , intArray is an array of type int
actually nothing is happening because it won't compile. This loop will automatically iterate this array & put the current value in i ( left side variable ) ....
Note :
1] your right hand side variable should have the values that is compatable
implicitly assignable to left hand side variable .
2] your right hand variable should be an array or iterator
An array or instance of java.lang.Iterable.
ofcourse , you can have code like this
if you want to test that the compiler will fail it int intArray = {1,2,3,4,5};
for(Integar i : intArray) { // boxing
System.out.print(i+" ");
}
*snip other stuff that won't compile*
Dude, misleading is worse than saying nothing at all.
You and the OP need to head to
http://java.sun.com/j2se/1.5.0/docs/guide/language/foreach.html