0

In this program, what is the importance of x++ ? can I replace with any other or delete permanently ?

int [ ] myArr = {6, 42, 3, 7}; int sum=0; for(int x=0; x<myArr.length; x++) { sum += myArr[x]; } System.out.println(sum);

26th Mar 2020, 3:47 PM
Gurmeet Singh
Gurmeet Singh - avatar
2 odpowiedzi
+ 1
If you remove that it will be Infinite loop... Please read the for loop tapic.. Explanation is clearly given.. If you don't understand, you can ask again... That is used to update x value for next iteration.. x++; x value updated by adding 1 x+=2; x value increamented by 2 .... https://www.sololearn.com/learn/Java/2147/
26th Mar 2020, 4:01 PM
Jayakrishna 🇮🇳