title: I am getting an "error: int cannot be dereferenced" for my program designed to sequentially, iteratively, and recursively search a .txt file
body: <p>In the main method, I've tried .equals() and .compareTo() and they both give me the same error at lines 88, 94, and 100. When I use ==, it compiles, but gives me the following when it runs:</p>
  
  <pre><code>Type the word you're searching for. Or type -1 to stop: curse
  sequentialSearch()      : curse is not found (comparison=13040).
  iterative binarySearch(): curse is not found (comparison=13).
  recursive binarySearch(): curse is not found (comparison=13).
  Type the word you're searching for. Or type -1 to stop:
  </code></pre>
  
  <p>I know the word "curse" is in the text file I'm searching.</p>
  
  <p>This is the code I have so far.</p>
  
  <pre><code>import java.io.*;
  import java.util.Scanner;
  import java.util.ArrayList;
  
  public class Search extends Object {
  public static final String TO_STOP = "-1";
  public static final int NOT_FOUND = -1;
  
  public static int count1;
  public static int count2;
  public static int count3;
  
  public Search()
  {
      count1 = 0;
      count2 = 0;
      count3 = 0;
  }
  
  public static int sequentialSearch(ArrayList&lt;String&gt; array, String value)
  {
      int low = 0;
      int high = array.size() - 1;
      for (int i = low; i &lt;= high; i++){
          count1++;
          if (array.get(i) == value)
              return i;
      }
      return NOT_FOUND;
  }
  
  public static int binarySearch(ArrayList&lt;String&gt; array, String value)
  {
      int low = 0;
              int high = array.size() - 1;
              while (low &lt;= high) {
                  int mid = (low + high)/2;
                  if (array.get(mid) != value){
                      count2++;
                      high = mid - 1;
                  } else if (array.get(mid) != value){
                      count2++;
                      low = mid + 1;
                  } else
                      return mid;
              }
      return NOT_FOUND;
  }
  
  public static int binarySearch(ArrayList&lt;String&gt; array, int low, int high, String value)
  {
      if (low &gt; high)
                  return NOT_FOUND;
              int mid = (low + high)/2;
              if (array.get(mid) != value){
                  count3++;
                  return binarySearch(array, low, mid-1, value);
              } else if (array.get(mid) != value){
                  count3++;
                  return binarySearch(array, mid+1, high, value);
              } else
          return mid;
  }
  
  public static void main (String [] args) throws IOException
  {
      ArrayList&lt;String&gt; array = new ArrayList&lt;String&gt;();
      File fn = new File("sortedWords.txt");
      Scanner sc = new Scanner(fn);
      Scanner keyboard = new Scanner(System.in);
      boolean wantsToContinue = true;
  
          while(sc.hasNextLine()){
          String ln = sc.nextLine();
          array.add(ln);
          }
  
          do {
              System.out.print("Type the word you're searching for. Or type " + TO_STOP + " to stop: ");
              String word2search = keyboard.nextLine();
  
              if(word2search.equals(TO_STOP)){
                  wantsToContinue = false;
              }
              else {
                  int index;
                  index = sequentialSearch(array, word2search);
                  if (index.compareTo(NOT_FOUND))
                      System.out.println("sequentialSearch()      : " + word2search + " is not found (comparison=" + count1 + ").");
                  else
                      System.out.println("sequentialSearch()      : " + word2search + " is found in [" + index + "] (comparison=" + count1 + ").");
  
                  index = binarySearch(array, word2search);
                  if (index.compareTo(NOT_FOUND))
                      System.out.println("iterative binarySearch(): " + word2search + " is not found (comparison=" + count2 + ").");
                  else
                      System.out.println("iterative binarySearch(): " + word2search + " is found in [" + index + "] (comparison=" + count2 + ").");
  
                  index = binarySearch(array, 0, array.size()-1, word2search);
                  if (index.compareTo(NOT_FOUND))
                      System.out.println("recursive binarySearch(): " + word2search + " is not found (comparison=" + count3 + ").");
                  else
                      System.out.println("recursive binarySearch(): " + word2search + " is found in [" + index + "] (comparison=" + count3 + ").");
                          }
      } while (wantsToContinue);
  }
  </code></pre>
  
  <p>}</p>