title: Java code not waiting for input at scanner
body: <p>I am creating a program written in Java using Eclipse, and JDK 8. I have created a <code>Scanner</code> using this code: <code>Scanner input = new Scanner(System.in);</code></p>
  
  <p>I then created a <code>String</code> using the code <code>String command = "no";</code></p>
  
  <p>I planned on using this string to control a <code>while</code> loop in my code, and a <code>switch</code> within the <code>while</code> loop. The loop starts with: <code>while(command = "no")</code> and within the <code>while</code> loop, I use the <code>Scanner</code> I created earlier to get the user to define values for a <code>String</code> and an <code>int</code>, which when the code is executed, works. After that (but still within the <code>while</code> loop, I put <code>command = input.nextLine();</code>, followed by <code>input.close();</code> on the line below, to set the value of the <code>command</code> string, and close the <code>Scanner</code>. But when I execute the code, it seems to skip that, and the <code>switch</code> which I put directly after that (which should also be controlled by the <code>command</code> string), and go on to code after the <code>while</code> loop, even though <code>command</code> is still set to "no", which should make the <code>while</code> loop start again.</p>
  
  <p>How do I make the code pause and wait for something to be entered at <code>command = input.nextLine();</code>, and how do i make the <code>switch</code> work like it should?</p>
  
  <p>Here is the entire code:</p>
  
  <p>`import java.util.Scanner;</p>
  
  <pre><code>class Human {
      private String name;
      private int age;
  
      public void setName(String name) {
          this.name = name;
      }
  
      public void setAge(int age) {
          this.age = age;
      }
  
      public String getName() {
          String name = this.name;
          return name;
      }
  
      public int getAge() {
          int age = this.age;
          return age;
      }
  }
  
  public class Asdfghjkl {
  
      public static void main(String[] args) {
  
          Scanner input = new Scanner(System.in);
  
          String command = "no";
  
          int age;
          String name;
  
          while(command == "no") {
              System.out.println("Welcome to HUMAN CREATOR");
              System.out.println("What is the human's name?");
              name = input.nextLine();
              System.out.println("Okay, its name is " + name + ".");
  
              System.out.println("What about its age?");
              age = input.nextInt();
              System.out.println(name + " is " + age + " years old.");
              System.out.println("Is this correct?");
              command = input.nextLine();
  
              switch (command) {
              case ("yes"):
                  System.out.println("Great! Lets make the human!");
                  Human h1 = new Human();
                  h1.setAge(age);
                  h1.setName(name);
  
              case ("no"):
                  System.out.println("Okay, lets start again.");
              }
          }
          System.out.println("qwerty");
              input.close();
      }
  }
  </code></pre>