Friday, February 20, 2009

Array with defaultvalues example



package arrays;

public class ArrayDefaultValues {


public static void main(String[] args) {
int a[];
a=new int[3];
System.out.println("a value is"+a);
int sum=0;
for (int i=0;i<a.length ;i++ )
{
System.out.println("\t"+a[i]);
sum=sum+a[i];
}
System.out.println("the sum of elements is"+sum);

}

}

output:
a value is[I@3e25a5
0
0
0
the sum of elements is0



0 comments:

Post a Comment