java - printing all the array value -
class arrayapp{ public static void main(final string[] args){ long [] arr; arr= new long[100]; int i; arr[0]=112; arr[1]=111; for(i=0;i<arr;i++) { system.out.println(arr[i]); } } }
i error,
arrayapp.java:10: operator < cannot applied int,long[] for(i=0;i<arr;i++) { ^
you need use size of array, arr.length
.
for (int = 0; < arr.length; ++i)
as of java 1.5, can use each loop if need access array data.
for ( long l : arr ) { system.out.println(l); }
Comments
Post a Comment