title: x-- causes if to loop infinitely
body: <p>I want to make something that if I type &quot;1&quot; the numbers will be ascending(x++) and if I type &quot;2&quot; it will be descending. x++ works fine but if I use x--, it will loop infinitely</p>
  <pre class="lang-java prettyprint-override"><code>public static void main(String[] args) {
      Scanner scan = new Scanner (System.in);
          
      System.out.print(&quot;Enter starting loop:&quot;);
      int start = scan.nextInt();
          
      System.out.print(&quot;Enter ending loop:&quot;);
      int end = scan.nextInt();
          
      System.out.print(&quot;Choose Order:&quot;);
      int n = scan.nextInt();
      if (n==1) {
          for (int x=start;x&lt;=end;x--){
              System.out.print(x + &quot;\t&quot;);
          }
      }   
  }
  </code></pre>