Question: import java.util.Scanner; public class New{ public static void main (String [] args){ int i = 0, j = 5; int s; while (j-- > 0)

import java.util.Scanner;

public class New{

public static void main (String [] args){

int i = 0, j = 5; int s;

while (j-- > 0) {

System.out.println ("J = " + j);

j--;

}

}

}

I have a basic question about the code above.

I just don't get how output is J=4 J=2 J=0

I thought the output will be J=4 J=3 J=2 J=1

Please help!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!