Would I just use a do while loop?
<p>I want the user to be able to search this short list but I don't want the JOptionPane to close if a wrong number is entered. Also how would I set up a terminate word ie if user types "quit" the loop will end and program will exit. Would I use a do while loop?</p>

<pre><code>  int key, list[] = {8,22,17,24,15};
  int index;

  key = Integer.parseInt(JOptionPane.showInputDialog(null,"Input the integer to find"));

  index = searchList(list, key);

  if(index &lt; list.length)
      JOptionPane.showMessageDialog(null,"The key " + key + " found the element " + index);
      else
      JOptionPane.showMessageDialog(null,"The key " + key + " not found");

     System.exit(0);


}

private static int searchList(int[] n, int k) {
    int i;
    for (i = 0; i &lt; n.length; i++)
        if(n[i] == k)
            break;   //break loop if key found
    return i;
</code></pre>
