Sunday, November 20, 2011

for each

Guess the output: public class ForEachDemo { public static void main(String args[]){ int a[]={1,8,1,1,1,1,1,1,1,1}; for(int i:a)//for each is for arrays display System.out.println(a[i]); } } Output: 8 1 8 8 8 8 8 8 8 8




Guess the output: public class ForEachDemo { public static void main(String args[]){ int a[]={1,8,1,1,1,1,1,1,1,1}; for(int i:a)//for each is for arrays display System.out.println(i); } }
output:
1 8 1 1 1 1 1 1 1 1

No comments:

Post a Comment

ec2-user@ec2 Permission denied