binary search program compiles but doesn't work
<pre><code>// program: BinSearch1.java
//
import java.util.*;

class BinSearch1
{
    public static void main(String[] args)
    {
        final int size = 50;
        Scanner console = new Scanner(System.in);

        // declaring arrays
        int[]  item = new int[size];    // The list of numbers
        int    items=0;     // number of values in list
        int location;
        int seekValue;

        // method returns number of items entered by user.
        // user enters –1 to end entry process.
        //
        items = createInOrder( item );

        System.out.println("Element\t\tValue");

        // Display the current list
        //
        for( int i=0; i &lt; items; i++ )
            System.out.println( i + "\t\t" + item[i] );

        System.out.print("Enter a value to seek: ");
        seekValue = console.nextInt();

        location = binSearch( item, items, seekValue);

        if( location &gt;= 0 )
          System.out.println("Element found at location " + location);
        else
          System.out.println("Element not found in list");
    }

    // method: createInOrder
    //   This method will fill in a previously created array with values
    // in increasing order. When complete the method will return the number
    // of values inserted into the list.
    //
    public static int createInOrder( int[] n )
    {
        int    i;
        int    value=0;
        int    items=0;
        Scanner console = new Scanner(System.in);

        while( items &lt; n.length &amp;&amp; value &gt;= 0 )
        {
            System.out.print("Enter a positive number to insert (negative to quit): ");
            value = console.nextInt();
            if( value &gt;= 0 )
            {
                // insert into array

                // step 1- locate the proper space for the item.
                i=0;
                while( i &lt; items &amp;&amp; n[i] &lt; value)
                    i++;

                // step 2- shift others down
                for( int j=items-1; j &gt;=i; j--)
                    n[j+1] = n[j];

                // step 3- insert new item
                n[i] = value;
                items++;

            }
        }

        console.close();
        // return number of values entered
        return items;   
    }

   // INSERT MISSING CODE HERE! Write method binSearch
   /*
   public static void binSearch(int[] x, int y, int j)
   {
       int v, a;
       int[] p;
       for(int i=0; i &lt; x.length; i++)
       {
           if(v &lt; x[i])
           {
               x[i]=a;
               return a;
           }
           if(v&gt; x[i])
           {
               x[i]/2=p[i];
               p[i]=a;
               return a;
           }

       }
   }
   public static void binSearch(int[] x, int y, int j)
   {
       int i;
       for(i=0; i&lt;y.length; i++)
       {
           if( y.length/2 == x[i])
           {
               if(
            }
       }
    }
    */

    public static int binSearch (int[] arrayName, int items, int seekItem ) 
{

  int bottom = 0;
  int top = arrayName.length - 1;
  int middle;
  boolean found = false;
  int location = -1;

  while (bottom &lt;= top &amp;&amp; !found) {

    middle = (bottom + top) / 2;

    if(arrayName[middle] == seekItem) {            
      found = true;
      location = middle;
    } else if (arrayName[middle] &lt; seekItem) {  
      bottom = middle + 1;
    } else {
      top = middle - 1;
    }
  }
  return location;
}


}
</code></pre>

<p>I'm writing this binary search program my teacher assigned. It compiles and I can put numbers, but when I try to seek the value and get the right index, it tells me the element is not in the list every time. What is wrong?</p>
