Public class test {
public static void main(String[] args){
int[] result = new int[5];
for (int i = 0; i < result.length; i++){
result[i] = i;
}
for (int value : result){
System.out.print (value);
}
}
}
I was wondering why is for needed with (int value : result) to print out to the console the array list properly. The output would be
0 1 2
but if we take out the for (int value : result) and just put System.out.print (result), the output would be
[[email protected]

New Topic/Question
Reply


MultiQuote





|