Monday, January 13, 2014

Java for programming Example

//Note:  Analysis the programs errors,outputs and Understand for  in Java 



//[1]


class Fordemo71
{
public static void main(String arg[])
{
String a[]={"one","amar","siva"};
for(String i:a){
System.out.println(i);
}
}
}

//[2]

class Fordemo70
{
public static void main(String arg[])
{
int a[]={1,2,3,4,5};
int sum=0;
for(int i:a){
System.out.println(i);
sum=sum+i;
}
System.out.println(sum);
}

No comments: