title: Java Scanner String Input If statement not working
body: <p>I am very new to java, and this seems very simple, perhaps I am missing something. </p>
  
  <p>Below is a little bit of my code, what it should do is have the user enter the a password, which is stored in userinput, unfortunately if I type admin which I have it set to == "admin" it will not work, even if I do all caps or all lowercase like I have it. </p>
  
  <p>I even tried pre-setting a variable such as String password = "admin"; and having it set to be if (userinput == password) but that did not seem to work either. Please help!</p>
  
  <pre><code>    }
      public void protect(){
          Scanner input = new Scanner(System.in);
          System.out.println("Enter password: ");
          String userinput = input.nextLine();
          if (userinput == "admin"){
              System.out.println("Correct!");
          } else if (userinput != "admin"){
              System.out.println("Wrong!");
          }
      }
  }
  </code></pre>
  
  <p>Quick summary, no matter what password I type, even if it is "admin" it goes right to wrong.</p>