java - While Loop not printing second command -


can tell me why second statement not print when counts gets below 4? first part prints "looping" part fine not print "no more loops". what's wrong?

enter code here  public class scratchpad {  public static void main(string[] args) {      int xray = 7;      while (xray > 4) {         system.out.println("looping");          if (xray < 4)             system.out.println("no more loops");         xray = xray - 1;      }  } 

when xray reaches value 4, while loop finishes. that's why second statement doesn't printed.

if want printed 1 solution one:

public class scratchpad {      public static void main(string[] args) {          int xray = 7;          while (xray >= 4){             system.out.println("looping");              if(xray <= 4)                 system.out.println("no more loops");              xray = xray-1;          }      }   }   

Comments

Popular posts from this blog

php - Autoloader issue not returning Class -

C++ Program To Find Smallest and Largest Number In Array -

java - How to put two numbers separated by a space into two different arrays -