title: Linear Search Array String
body: <p>I need to find a string element in my array but when I check to see, it always comes up as found, even if its not the case. I am trying to call a method.</p>
  
  <pre><code>    String name = "";
      boolean result = false;
  
  
  
  
     if (option == 5)
              {
          System.out.println("Please enter a students name");
          name = input.next();
  
          linearSearch(student);
  
  
          if (result = true)
          {System.out.println(name+" found in element ");}
  
          else
          {System.out.println(name+" not found in element ");}
  
  
      }
  
  
  public static boolean linearSearch(String b[])
  {
  String key = null;
  boolean searchReturn = false;
  for(int i = 0; i &lt; b.length; i++)
  {
      //if key is found - return position of key i.e. n
      if( b[i] == key)
      searchReturn = true;
  }
  
  return searchReturn;
  </code></pre>