title: Finding the smallest integer based on input
body: <p>I have an assignment to find the minimum, maximum, and average of numbers that a user inputs. Basically, they type in positive integers, seperated by a space and Java scrolls through them and adds them up. I'm able to find the sum, the average, and the largest integers, however, I am unable to find the smallest. I thought the best way to figure this out would be to set the variable representing the smallest int equal to the variable representing the largest int outside of the loop. Then, within the loop, do something like this:</p>
  
  <pre><code>        if(getInt &lt; min)
          {
              min = getInt;
          }
  </code></pre>
  
  <p>Where getInt is the user-inputted value and min is the minimum integer value. Every time I run this, though, min returns as 0.</p>
  
  <p>Here is my full code:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class exc5
  {
      public static void main (String[] args)
      {  
          System.out.println("Write a list of nonnegative integers, each seperated by a space. To signal the end of the list, write a negative integer. The negative integer will not be counted");
          Scanner keyboard = new Scanner (System.in);
          keyboard.useDelimiter(" |\n");
  
          int count = 0;
          int sum = 0;
          int max = 0;
          int min = max;
          double average = 0;
  
          boolean notNull = true;
  
          while(notNull == true)
          {
              int getInt = keyboard.nextInt();
  
              if(getInt &lt; 0)
              {
                  notNull = false;
              }  
              else
              {          
                  if(getInt &gt; max)
                  {
                      max = getInt;
                  }
  
                  if(getInt &lt; min)
                  {
                      min = getInt;
                  }
  
                  sum += getInt;
                  count++;
                  average = (sum)/(count);
              }
          }
  
          System.out.println("Sum = " + sum);
          System.out.println("Average = " + average);
          System.out.println("Max = " + max);
          System.out.println("Minimum = " + min);
      }
  
  }
  </code></pre>
  
  <p>Any help is appreciated!</p>