title: Java list log im validation method
body: <p>I'm new to java and I'm trying to do a log in with a list, but the validation method does not work.</p>
  
  <p>I've tried accessing the value of the list with the counter and the tried assigning it to a variable, in the debug mode the value i'm getting is correct but the condition still does not work (user: test, password test)</p>
  
  <p>This is my user class with the methods to set and get the password.</p>
  
  <pre><code>public class user {
      String user;
      String pass;
  
  
      public user(String u, String p) {
          user = u;
          pass = p;
  
      }
  
      public String getUsername() {
          return user;
      }
  
      public String getPassword() {
  
          return pass;
  
      }
  
      public void setUsername(String username) {
          this.user = username;
      }
  
      public void setPassword(String password) {
          this.user = password;
      }
  }
  </code></pre>
  
  <p>This is the log in class</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.Scanner;
  
  public class LogIn {
      public void Welcome() {
  
          System.out.println("Welcome, please enter your username");
          Scanner input = new Scanner(System.in);
           String username = input.next();
          System.out.println("Enter your password");
           String password = input.next();
           this.validate(username);
  
      }
  
      private void validate(String username){
          int attemps = 0;
          ArrayList&lt;user&gt; users = new ArrayList&lt;user&gt;();
          user User = new user("test", "test");
  //Here I add the new user with the fixed value of test for password and user
          users.add(User);
          for(int i=0; i&lt;=users.size()-1;i++){
              while (attemps&lt;=3){
                   System.out.println(users.get(i).getUsername());
                   String test = users.get(i).getUsername();
  
  //This condition here is the one not working and with the user already added to the list and getting the correct value in the variable it still does not work
                  if(username == test){
                      System.out.println("Here");
                      attemps = 3;
                   }else{
                      System.out.println("invalid credentials");
                      attemps++;
                  }}
                  System.out.println("You have exceed the number of attempts");
  
              }
          }
      }
  </code></pre>
  
  <p>Using the credentials test for the user and test on the password it doesn't work</p>