The last two lines should clue you in:
one has y++
before the closing brace, and the other has it after. In the first, y
will be incremented each time the loop runs, right before a=a+y
is executed. In the second, y
will be incremented after the loop ends.
More Related Contents:
- What's the output of this code written in java?
- How do you invoke a method? [closed]
- How to construct a loop that produces a temp conversion chart
- how many loops is this running? – java coding
- Basic Looping in Java
- Nested for loop in java. Am I allowed to declare a variable in the outer and increment it in the inner?
- How to add two int array values together?
- Why do we multiply 2 inside the for loop?
- Why is printing “B” dramatically slower than printing “#”?
- Is there a performance difference between a for loop and a for-each loop?
- How does a for loop work, specifically for(;;)?
- Is there a way to access an iteration-counter in Java’s for-each loop?
- ConcurrentModificationException when adding inside a foreach loop in ArrayList [duplicate]
- A for-loop to iterate over an enum in Java
- How to get a index value from foreach loop in jstl
- Initializing an array in Java using the ‘advanced’ for each loop [duplicate]
- Misplaced semicolon in for loop [closed]
- Last iteration of enhanced for loop in java
- Iterator vs for
- Is there any way to do n-level nested loops in Java?
- Java for loop vs. while loop. Performance difference?
- Java 8 forEach with index [duplicate]
- Technical reasons behind formatting when incrementing by 1 in a ‘for’ loop?
- Switch executes all case statements
- Breaking out of a for loop in Java [closed]
- How to remove last comma and space in array? Java [duplicate]
- Java for-loop optimization
- Java: Best way to iterate through a Collection (here ArrayList)
- Java 8: Parallel FOR loop
- How can I run multiple commands in just one cmd windows in Java?