title: java scanner does not accept two words with space in between
body: <p>I'm trying to create a simple project that will ask the user true or false and if true then the scanner is gonna keep storing the category name in an arraylist.
  And it works fine until you enter two words with a space in the category name "first second" for example for some reason it jump into the condition true or false and check that i have entered another word than true or false and execute the catch clause .
  I've tried using both scanner.next or nextline , nextline just jump into true or false without asking for category name.
  Please help.
  Thank you so much.</p>
  
  <pre><code>public class MainClass {
  
  
  public static boolean check = false;
  public static void main(String[] args) {
      Scanner in = new Scanner(System.in);
  
      Categories c = new Categories();
  
      System.out.println("Please enter true if you want to add a category \n or false if not");
  
      try {
          check = in.nextBoolean();
      } catch (InputMismatchException e) {
          System.out.println("Sorry you must put true or false!!!");
          System.exit(0);
  
              }
  
  
      while (check) {
          System.out.println("Please enter category name");
          c.category.add(in.next().toString());
          System.out.println("do you want to add more true or false");
  
          try {
              check = in.nextBoolean();
          } catch (InputMismatchException e) {
              System.out.println("Sorry you must put true or false!!!");
              System.exit(0);
          }
  
      }
  
      System.out.println("Thank you all categories are added");
      System.out.println(c.category);
  
  
  
  
  
  }
  </code></pre>
  
  <p>}</p>