older version:
int a[]={1,2,3,4,5};
for(int i=0;i<a.length;i++)
{
System.out.println("values is:"+a[i]);
}
Newer form i.e java1.5version:
for(int b:a)--------------------------------------------->// here internally it will be expand like this
{ // for(int i=0;i<a.length;i++)
System.out.println("values is:"+b); // {
} // int b=a[i];
// }
2nd Example
for(int i=0;i<a.length;i++)
{
System.out.println("Element is:"+array[i]);
}
to the newer form
for(Strting element : array)
{
System.out.println("Element:"+element);
}
int a[]={1,2,3,4,5};
for(int i=0;i<a.length;i++)
{
System.out.println("values is:"+a[i]);
}
Newer form i.e java1.5version:
for(int b:a)--------------------------------------------->// here internally it will be expand like this
{ // for(int i=0;i<a.length;i++)
System.out.println("values is:"+b); // {
} // int b=a[i];
// }
2nd Example
for(int i=0;i<a.length;i++)
{
System.out.println("Element is:"+array[i]);
}
to the newer form
for(Strting element : array)
{
System.out.println("Element:"+element);
}
No comments:
Post a Comment