title: How to show certain numbers from an Array in Java?
body: <p>I want to single out only positive numbers in one line and only negative numbers in one line, but they only show one by one with the text.
  Here's my code:</p>
  
  <pre><code>int[] array = {2, -5, 4, 12, 54, -2, -50, 150};
      Arrays.sort(array);
      for (int i = 0; i &lt; array.length; i++) {
          if (array[i] &lt; 0) {
              System.out.println("Less than 0: " + array[i]);
  
          } else if (array[i] &gt; 0) {
              System.out.println("Greater than 0: " + array[i]);
          }
  
      }
  </code></pre>