0
Can someone please explain this code line to me in a super simple way, and reasons to use it? I'm just starting the code journey
for (int i = 1; i <= maxNumber; ++i) { System.out.print(previousNumber+" ");
3 Answers
0
A For loop is one of the most fundamental concepts in programming. You use it for iterations.
That line of code is telling the computer to set a integer variable name i to 1 and while i is lesser or equal to another variable called maxNumber, that should be defined before, it's going to print the variable previousNumber plus space. The ++1 tells the computer to increment the variable i by 1 after each iteration, in this case, i is equal to 2 now. Then the system checks if the condition (i <= maxNumber) is met. It's not, so it repeats the process until the condition is met.
+ 1
Thank you man, makes it a bit more clear now. This is a lot of stuff to learn. Overwhelming at times on where to start and what direction to go with things.
0
The area certainly demand us to be life long learners, but it's certainly worth it. My advice for your is: divide and conquer. Best of luck in your journey.