title: Is it possible to split this up into multiple methods?
body: <p>I was working on an array program where the program would accept 10 numbers and output them in ascending order. The code itself works fine, but I was wondering if I could get help with splitting the code into 2 different methods. (eg: sorting as a separate method)</p>
  <p>Here is my code</p>
  <pre><code>import java.util.Scanner;
  class arrayProgram {
      public static void main(String[] args) {
          double count;
          count = 10;
          double temp;
  
  
          Scanner scan = new Scanner(System.in);
  
          try {
              double num[] = new double[(int) count];
              System.out.println(&quot;Enter array elements:&quot;);
              for (double i = 0; i &lt; count; i++) {
                  num[(int) i] = scan.nextDouble();
              }
              scan.close();
              for (double i = 0; i &lt; count; i++) {
                  for (double j = i + 1; j &lt; count; j++) {
                      if (num[(int) i] &gt; num[(int) j]) {
                          temp = num[(int) i];
                          num[(int) i] = num[(int) j];
                          num[(int) j] = temp;
                      }
                  }
              }
              System.out.print(&quot;Array Elements in Ascending Order: &quot;);
              for (int i = 0; i &lt; count - 1; i++) {
                  System.out.print(num[i] + &quot;, &quot;);
              }
              System.out.print(num[(int) (count - 1)]);
          } catch (Exception e) {
              System.out.println(&quot;Error!&quot;);
          }
      }
  }
  </code></pre>