0

Please I don’t understand the purpose of the second loop

I do have an array of objects(a counter type) And the increment the value of the array by 1 —I do want to print the sum of the array It gives 4950 as a results —I don’t understand the purpose of the second loop for (j=0;j<I;j++) Why J is inferior than I I don’t get it… https://code.sololearn.com/cCJA1ooJZNWL/?ref=app

1st Dec 2021, 7:03 PM
Amal Gil
Amal Gil - avatar
2 ответов
+ 1
// I hope this will be of some help int[] tab = new int[100]; Counter c = new Counter(); for(int i=0;i<100;i++){ c.up(); tab[i] = c.getValue(); sum= sum + tab[i]; }
1st Dec 2021, 11:53 PM
SoloProg
SoloProg - avatar
0
I think there is error regarding to constructor. 1+(1+1) +(1+1+1) +(1+1+1+1) +....... This is the output the program is going to produce .. Run from urself u may get idea by observing the output
1st Dec 2021, 7:28 PM
Pranshu Sachan