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 - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -