Saturday, January 8, 2011

make use foreach loop in java

int i[] = {1,2,3,4,5}

// now, if we want to iterate through each item of array i, then we can use foreach loop like this


for( int temp_var : i )
{


System.out.println ( temp_var)
}


o/p:

1
2
3
4
5

No comments:

Post a Comment