java debuging doesn’t show current line correctly in netBeans

I have a simple java class, and I set a break point at main method and step by clicking ‘step into’ (netbeans).

Expected:

green line goes to line 4 and 5 until loop ends

What happens:

It stays at line 4.

I can see in the console that the value of i get printed.
If i gets printed, that mean it should go to line 5 which is System.out.print(i+" > ");.

Why it stays at line 4 until loop ends ?

Here is the preview:

enter image description here

This is the code i’m debugging:

2 | public class NewClass2 {
3 |     public static void main(String[] args) {
4 |         for (int i = 0; i < 10; i++) {
5 |             System.out.print(i+" > ");
6 |         }
7 |         System.out.println("end of the loop");
8 |     }
9 | }


Source: java

Leave a Reply