title: Java Scanner Continuous User input?
body: <p>For java practice, i am trying to create a program that reads integers from the keyboard until a negative one is entered.</p>
  
  <p>and it prints the maximum and minimum of the integer ignoring the negative.</p>
  
  <p>Is there a way to have continuous input in the same program once it runs? I have to keep running the program each time to enter a number.</p>
  
  <p>Any help would be appreciated</p>
  
  <pre><code>public class CS {
      public static void main(String []args) {
  
          Scanner keys = new Scanner(System.in);
          System.out.println("Enter a number: ");
          int n = keys.nextInt();
  
          while(true)
          {
              if(n&gt;0)
              {
                  System.out.println("Enter again: ");
                  n = keys.nextInt();
              }
              else
              {
                  System.out.println("Number is negative! System Shutdown!");
                  System.exit(1);
              }
  
          }
      }
  }
  </code></pre>
  
  <p>Here is a part of my code - It works, but i think there is an easier way of doing what i want but not sure how!</p>