title: Passing String variables to Java method not working, but hard-coded string working?
body: <p>I'm having a strange issue. I'm trying to pass a number of String variables denoting a user's dislikes to a predefined Java method that works by comparing these dislikes to the key ingredients stored as a String array in a Recipe object array. </p>
  
  <p>The method works fine when I hard-code a dislike, such as "Beef", but when I assign the dislikes to an instance String variable kw1 using user1.getDislikes(0), the method does not perform correctly - it returns recipes that have "Beef" as a keyword, when it shouldn't.</p>
  
  <p>I know the String is being passed and assigned correctly as I used a Toast to display kw1 upon returning valid results. </p>
  
  <p>I've tried adding toString() in numerous places as IntelliJ was being picky about it earlier, despite claiming it is redundant, but it hasn't worked here. </p>
  
  <p>Here's the section I'm having difficulty with:</p>
  
  <pre><code>if ((SetRecipes.recipes[index].searchkeywords2(kw1, kw2, kw3))) //Not working unless words (e.g. "Beef") are hardcoded for some reason. kw1 variable being assigned correctly, as shown by Toast.
           {
              temp[validRecipe] = index;
  
              validRecipe++;
           } //if
  </code></pre>
  
  <p>The full code can be found below. Any help is greatly appreciated!</p>
  
  <pre><code>public class SuggestResult extends Activity
  {
  
     String kw1, kw2, kw3;
  
     static TextView [] recipeText = new TextView[8];
  
     @Override
     public void onCreate(Bundle savedInstanceState)
     {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.suggest_results);
        User user1 = (User)getIntent().getSerializableExtra("user1");
  
        kw1 = user1.getDislikes(0).toString();
        kw2 = user1.getDislikes(1).toString();
        kw3 = user1.getDislikes(2).toString();
  
        /*
        kw1 = "null";
        kw2 = "null";
        kw3 = "null";
        */
  
        recipeText[0] = (TextView)findViewById(R.id.recipeSuggestText1);
        recipeText[1] = (TextView)findViewById(R.id.recipeSuggestText2);
        recipeText[2] = (TextView)findViewById(R.id.recipeSuggestText3);
        recipeText[3] = (TextView)findViewById(R.id.recipeSuggestText4);
        recipeText[4] = (TextView)findViewById(R.id.recipeSuggestText5);
        recipeText[5] = (TextView)findViewById(R.id.recipeSuggestText6);
  
        final int MAXRECIPES = 7;
        final int MAXTEXTFIELDS = 6;
        int[] temp = new int[MAXRECIPES];
        int validRecipe = 0;
  
        SetRecipes.setArray();
  
        for (int index = 0; index &lt; MAXRECIPES; index++)
        {
  
  
           if ((SetRecipes.recipes[index].searchkeywords2(kw1, kw2, kw3))) //Not working unless words (e.g. "Beef") are hardcoded for some reason. kw1 variable being assigned correctly, as shown by Toast.
           {
              temp[validRecipe] = index;
  
              validRecipe++;
           } //if
        }
  
        if (validRecipe == 0)
        {
           Context context = getApplicationContext();
           CharSequence text = "No valid recipes found!";
           int duration = Toast.LENGTH_SHORT;
           Toast toast = Toast.makeText(context, text, duration);
           toast.show();
        }
  
        for (int index3 = 0; (index3 &lt; validRecipe) &amp;&amp; (index3 &lt; MAXTEXTFIELDS); index3++)
        {
           recipeText[index3].setText((SetRecipes.recipes[temp[index3]].getName()).toString());
  
        }
  
  
        Context context = getApplicationContext();
        CharSequence text2 = kw1;
        int duration = Toast.LENGTH_SHORT;
        Toast toast = Toast.makeText(context, text2, duration);
        toast.show();
  
  
       }
  
  }
  </code></pre>
  
  <p>searchkeywords2 method:</p>
  
  <pre><code>public boolean searchkeywords2(String choice1,String choice2, String choice3)
      {
          int ingredientsPresent = 0;
  
  
          for (int index = 0; index &lt; keywords.length; index++)
          {
              if ((keywords[index] == choice1) || (keywords[index] == choice2) || (keywords[index] == choice3))
              {
                  ingredientsPresent++;
              }
          }
          if (ingredientsPresent == 0)
          {
              return true;
          } else
          {
              return false;
          }
  
  
      }
  </code></pre>