title: Collect User Inputs in Array and Print Sorted in Java
body: <p>I'm trying to gather user inputs and sort them after the input "bye" is given. However I don't understand how to accomplish the "bye" part.
  Here is what I have so far. Can someone explain why I can't add nextLine() instead of nextInt() and change things to Strings. I could then break out of the while statement with the string "bye" but none of it has worked for me so far.</p>
  
  <pre><code>import java.util.*; 
  
  public class Work {
    public static void main(String[] args) {
      Scanner s = new Scanner(System.in);
      int[] values = new int[1];
      int currentSize = 0;
      System.out.print("Type a number ");
      while( s.hasNextInt())
      {
        if(currentSize &gt;= values.length)
        {
          values = Arrays.copyOf(values, values.length + 1);
        }
        System.out.print("Type: ");
        values[currentSize] = s.nextInt();
        currentSize++;
        Arrays.sort(values);
        System.out.print(Arrays.toString( values ) );
      }
  
    }
  }
  </code></pre>