title: Java youngest and oldest in an array of n
body: <p>I have written a program to find the oldest and youngest person based on the ages and names that I have entered. The problem is, the program only gives me the oldest person, the else if statement for the youngest doesn't execute.</p>
  
  <pre><code>public class Boo {
  
  public static void main(String[] strings) {
  
    int[] age = new int[10];
    String[] name = new String[10];
    int count = 0;
  
    Scanner in = new Scanner(System.in);
  
    boolean notDone = true;
  
    int smallest = age[0];
    int largest = age[0];
  
    String smalName = "";
    String larName = "";
  
  
  do {
  
  
    System.out.println("Enter name");
    name[count] = in.next();
  
  
  
    if (!name[count].equalsIgnoreCase("done")) {
      System.out.println("Enter age");
      age[count] = in.nextInt();
  
      if (age[count] &gt; largest) {
        largest = age[count];
        larName = name[count];
      }
      else if (age[count] &lt; smallest) {
        smallest = age[count];
        smalName = name[count];
      }
  
    }
    else if (name[count].equalsIgnoreCase("done")) {
      notDone = false;
    }
  
    count++;
  
  }while(notDone &amp;&amp; count &lt; 3);
  </code></pre>