can anyone explain me the working | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
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

12th Jun 2020, 10:04 PM
Diksha Jadhav
2 Antworten
+ 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
12th Jun 2020, 10:12 PM
Abhay
Abhay - avatar
0
sorry but i still did not get it can you please give a dry run with explaination please ?
12th Jun 2020, 10:34 PM
Diksha Jadhav