问题描述:

This question already has an answer here:

  • How do I compare strings in Java?

    23 answers

网友答案:

In java Strings are compared with equals and not ==. The reason is, strings are objects and not primitives. See Java == vs equals() confusion for more information about == and equals()

So the if expression is wrong:

username.getText().equals(dbUser.get(i)) && password.getText().equals( dbPassword.get(i))
网友答案:

If you want to compare Strings use equals method, == will compare addresses

So change

if(username.getText() == dbUser.get(i) && password.getText()== dbPassword.get(i))

to

if(username.getText().equals(dbUser.get(i)) && password.getText().equals(dbPassword.get(i)))
相关阅读:
Top