title: My array takes in the sentinel value as an array element and then terminates
body: <p>I am writing a program that takes in user input and churns out the minimum value.
  After 10 inputs the user can type in a negative number as the sentinel to exit the loop.
  The problem is this works but for some reason the loop takes the sentinel value as an array element aswell. Can anyone tell me whats wrong?</p>
  
  <pre><code>public class java {
  
     public static void main(String[] args) {
     {
  
        double[] a=new double[10];
        Scanner arr=new Scanner(System.in);
  
        System.out.println("Please enter values");
  
        int size = 0;
  
        int x = 0;
  
        while ( x &gt;= 0 )
        {
           System.out.println("Enter next value");    
           x = arr.nextInt();
  
           a[size]=x;
           size++;                   
        }
  
        System.out.println( "Minimum Value" );
  
        System.out.println((min(a)));
     }
  }
  
  public static double min( double[] arr )
  {
     double minimum= arr[0];
     for (int i=1; i&lt;arr.length; i++)
     {
        if (arr[i] &lt; minimum)
        {
           minimum= arr[i];
        }
     }
  
     return minimum;
  }
  </code></pre>