for(int i = 0; i < 3; i++){
for(int j=0; j < 5; j++){
nums[j] = (i+1)*(j+1);
}
}
for(int x[] : nums) {
for(int y : x) {
System.out.println(“Value is: ” + y);
sum += y;
}
}
System.out.println(“Summation: ” + sum);
}
}
The output from this program is shown here:
Value is: 1
Value is: 2
Value is: 3
Value is: 4
Value is: 5
Value is: 2
Value is: 4
Value is: 6
Value is: 8
Value is: 10
Value is: 3
Value is: 6
Value is: 9
Value is: 12
Value is: 15
Summation: 90
Out put of this array seems to be confusing :(
It should be something like this, 1, 4, 9 instead of 1,2,3
what is actually happening?