title: while loop: while sentence does not contain a word
body: <p>I'm getting user input and checking to see if the word 'java' is in the sentence.  I did a while loop but even when the word 'java' is in the sentence, it tells me that it's not and continues with the while loop.  If I remove the while loop, everything else that I want my program to do works.  here is the code:</p>
  
  <pre><code>import java.util.Scanner;
  
      public class Main {
  
      public static void main(String[] args) {
  
          //declare all variables
          String sentence;
          int java_index_number;
          String stop_program;
          String java;
          String Java;
          String JAVA;
          String java_capital_first_letter;
          String java_all_caps;
  
          //scanner to get user input
          Scanner user_input = new Scanner(System.in);
  
          //prompt the user for a sentence
          System.out.print("Enter a line of text containing the word 'java' somewhere within it: ");
          sentence = user_input.nextLine();
  
          java = "java";
          Java = "Java";
          JAVA = "JAVA";
          while(!sentence.contains(java) || !sentence.contains(Java) || !sentence.contains(JAVA)) {
              System.out.println("Your sentence does not have the word 'java' within it.");
              System.out.print("Enter a line of text containing the word 'java' somewhere within it: ");
              sentence = user_input.nextLine();
          }
  
          //output
          System.out.println();
          System.out.println("The string read is: " + sentence);
          System.out.println("Length in chars is: " + sentence.length());
          System.out.println("All lowercase is: " + sentence.toLowerCase());
          System.out.println("All uppercase is is: " + sentence.toUpperCase());
  
          //store java index pos in variable
          java_index_number = sentence.indexOf("java");
          System.out.println("Found 'java' or at pos: " + java_index_number);
  
  
          //make first letter of java a capital letter
          java_capital_first_letter = sentence.substring(0, java_index_number) + sentence.substring(java_index_number,
                  java_index_number + 1).toUpperCase() + sentence.substring(java_index_number + 1, java_index_number + 4)
                  + sentence.substring(java_index_number + 4);
  
          //make java all caps
          java_all_caps = sentence.substring(0, java_index_number) + sentence.substring(java_index_number,
                  java_index_number + 4).toUpperCase() + sentence.substring(java_index_number + 4);
  
          //output
          System.out.println("Changing to 'Java': " + java_capital_first_letter);
          System.out.println("Changing to 'JAVA': " + java_all_caps);
  
          // Keep console window alive until 'enter' pressed
          System.out.println();
          System.out.println("Done - press enter key to end program");
          stop_program = user_input.nextLine();
  
  
      }
  }
  </code></pre>
  
  <p>How do I get the while loop to work?</p>
  
  <p>UPDATE: after the awesome feedback that I got, I finally got it to work.. Thanks everyone who helped!</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Main {
  
      public static void main(String[] args) {
  
          //declare all variables
          String sentence;
          int java_index_number;
          String stop_program;
          String java_capital_first_letter;
          String java_all_caps;
  
          //scanner to get user input
          Scanner user_input = new Scanner(System.in);
  
          //prompt the user for a sentence
          System.out.print("Enter a line of text containing the word 'java' somewhere within it: ");
          sentence = user_input.nextLine();
  
  
          while(!sentence.toLowerCase().contains("java")) {
              System.out.println("Your sentence does not have the word 'java' within it.");
              System.out.print("Enter a line of text containing the word 'java' somewhere within it: ");
              sentence = user_input.nextLine();
          }
  
          //output
          System.out.println();
          System.out.println("The string read is: " + sentence);
          System.out.println("Length in chars is: " + sentence.length());
          System.out.println("All lowercase is: " + sentence.toLowerCase());
          System.out.println("All uppercase is is: " + sentence.toUpperCase());
  
          //store java index pos in variable
          sentence = sentence.toLowerCase();
          java_index_number = sentence.indexOf("java");
          System.out.println("Found 'java' or at pos: " + java_index_number);
  
  
          //make first letter of java a capital letter
          java_capital_first_letter = sentence.substring(0, java_index_number) + sentence.substring(java_index_number,
                  java_index_number + 1).toUpperCase() + sentence.substring(java_index_number + 1, java_index_number + 4)
                  + sentence.substring(java_index_number + 4);
  
          //make java all caps
          java_all_caps = sentence.substring(0, java_index_number) + sentence.substring(java_index_number,
                  java_index_number + 4).toUpperCase() + sentence.substring(java_index_number + 4);
  
          //output
          System.out.println("Changing to 'Java': " + java_capital_first_letter);
          System.out.println("Changing to 'JAVA': " + java_all_caps);
  
          // Keep console window alive until 'enter' pressed
          System.out.println();
          System.out.println("Done - press enter key to end program");
          stop_program = user_input.nextLine();
  
  
      }
  }
  </code></pre>