0
can anyone explain me the working
public class Program { public static void main(String[] args) {int [ ] myArr = {6, 42, 3, 7}; int sum=0; for(int x=0; x<myArr.length; x++) { sum += myArr[x]; } System.out.println(sum); // 58
3 Answers
+ 2
for loop runs 4 times with x value increasing by 1
sum=sum+myArr[x] adds the value at index x to sum then
0
sorry but i still did not get it can you please give a dry run with explaination please
?