title: ascending sort without using arrays in java
body: <p>This code has to enter 5 integers and then display them in ascending and descending orders without using arrays. But it gives me only the biggest number. How can i do it without arrays??</p>
  
  <pre><code>package assignment;
  
  import javax.swing.JOptionPane;
  
  public class q1 {
  
      public static void main(String[] args) {
  
          String a = JOptionPane.showInputDialog(null, "Please Enter a number", "Input", JOptionPane.QUESTION_MESSAGE);
          int number1 = Integer.parseInt(a);
          String b = JOptionPane.showInputDialog(null, "Please Enter a number", "Input", JOptionPane.QUESTION_MESSAGE);
          int number2 = Integer.parseInt(b);
          String c = JOptionPane.showInputDialog(null, "Please Enter a number", "Input", JOptionPane.QUESTION_MESSAGE);
          int number3 = Integer.parseInt(c);
          String d = JOptionPane.showInputDialog(null, "Please Enter a number", "Input", JOptionPane.QUESTION_MESSAGE);
          int number4 = Integer.parseInt(d);
          String e = JOptionPane.showInputDialog(null, "Please Enter a number", "Input", JOptionPane.QUESTION_MESSAGE);
          int number5 = Integer.parseInt(e);
  
          if (number1 &gt; number2 &amp;&amp; number1 &gt; number3 &amp;&amp; number1 &gt; number4 &amp;&amp; number1 &gt; number5) {
              System.out.print(number1 + ",");
          } else if (number2 &gt; number1 &amp;&amp; number2 &gt; number3 &amp;&amp; number2 &gt; number4 &amp;&amp; number2 &gt; number5) {
              System.out.print(number2 + ",");
          } else if (number3 &gt; number1 &amp;&amp; number3 &gt; number2 &amp;&amp; number3 &gt; number4 &amp;&amp; number3 &gt; number5) {
              System.out.print(number3 + ",");
          } else if (number4 &gt; number1 &amp;&amp; number4 &gt; number2 &amp;&amp; number4 &gt; number3 &amp;&amp; number4 &gt; number5) {
              System.out.print(number4 + ",");
          } else if (number5 &gt; number1 &amp;&amp; number5 &gt; number2 &amp;&amp; number5 &gt; number3 &amp;&amp; number5 &gt; number4) {
              System.out.print(number5 + ",");
          }
  
      }
  }
  </code></pre>