title: Java Binary search not working
body: <p>I have an insertion search in the main and from there I call the BinarySearch method to search for a number within the array that has already been sorted. I try to compile it I get errors here is my main with the insertion sort.</p>
  
  <pre><code>public class test5
  {
   public static void main(String[] args)
   {
  
  // original order or numbers
  System.out.println("Original order of numbers:");
  int nums[] = {26, 45, 56, 12, 78, 74, 39, 22, 5, 90, 87, 32, 28, 11, 93, 62, 79, 53, 22, 51};
  
  for(int x = 0; x &lt; nums.length; x++){
  System.out.print(nums[x] + " ");
  }
  
  
  // local variables
  int unsortedValue; // The first unsorted value
  int scan; // used to scan the array
  int swapCount = 0;
  
  
  // the other loop steps the index variable through 
  // each subscript in the array, starting at 1. This
  // is because element 0 is considered already sorted.
  for(int index = 1; index &lt; nums.length; index++)
  {
      // The first element outside the sorted subset is
      // nums[index]. Store the value of this elementt
      // in unsortedValue.
      unsortedValue = nums[index];
  
      // Start the scan at the subscript of the first element
      // into its proper position within the sorted subset.
      scan = index;
  
      // Move the first element outside the sorted subset
      // into its proper position within the sorted subset.
      while(scan &gt; 0 &amp;&amp; nums[scan-1] &gt; unsortedValue)
      {
          nums[scan] = nums[scan -1];
          scan--;
  
      }
  
      // Insert the unsorted value in its proper position
      // within the sorted subset.
      nums[scan] = unsortedValue;
      swapCount++;
          }
  
      //  print out results of swap and swapCount
      System.out.println();
      System.out.println("Insertion sort: ");
  
      for(int index = 0; index &lt; nums.length; index++){   
              System.out.print(nums[index] + " ");
                          }
  
      System.out.println();
      System.out.println("The swap count is: " + swapCount);
      BinarySearch(nums);
      }
  </code></pre>
  
  <p>Here is the method for the binary search</p>
  
  <pre><code>public static int BinarySerach(String[] array, String value)
  {
  Scanner keyboard = new Scanner(System.in);
  
  System.out.print("Enter target: ");
  int target = nums.nextInt();
  int index = -1;
  int left = 0;
  int right = nums.length - 1; 
  int middle;
  while(left &lt;= right){
      middle = (left + right)/2;
      if(nums[middle] == target){
          index = middle;
          break;
      } else if (nums[middle] &gt; target) {
          right = middle - 1;
      }else{
          left = middle + 1;
      }
  }
  if(index == -1){
      System.out.println("element not found");
  }else{
      System.out.println("element found at index " + index);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Errors I get are cannot find symbol.</p>