title: Input and save answer
body: <p>So I want to ask the user to input some details like name etc, and then add them to an ArrayList. If the user enters blank spaces a message will be shown and the user will be asked to enter again.</p>
  
  <pre><code>System.out.println("Name: ");
  
  String name = input.nextLine();
  
  while(name.contains(" ")){
  
  System.out("Names can't be empty");
  
  System.out.println("Name: ");
  
  name = input.nextLine();
  
  }
  
  Person newP = new Person(name);
  
  persons.add(newP);
  </code></pre>
  
  <p>Code works fine if the user enters some characters. However if he doesn't and enters the while loop, what gets added is just the blank spaces. </p>
  
  <p>What can I do to make sure it adds the input inside the loop? </p>