+ 2

I have a question about some java code please

Every time I run my program, and enter "Dustin" as the password, it keeps sending me to my else statement and not to my welcome() method. I have it printing variable a, and b. Which is the input from user, and the password drawn from a multidimensional array. They both match, so I used: if(a == b) { welcome(); } else { System.out.println("Wrong password"); }

4th Jan 2019, 8:00 AM
Dustin James Locey
Dustin James Locey - avatar
4 Answers
+ 18
● use (a.equals(b)) in if() condition 👍 ● .equals() Method is used for content comparision , on the other hand == Operator is used for reference comparision.
4th Jan 2019, 8:12 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 14
Sekiro Probabaly he is having doubt in this code : https://code.sololearn.com/cq0uzM0u5GeJ/?ref=app Dustin James Locey u can link the code for making your question more clear to community & get community help 👍
4th Jan 2019, 8:15 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 4
I'm sorry. I forgot to link it. But I got it working. Thank you :)
4th Jan 2019, 8:38 AM
Dustin James Locey
Dustin James Locey - avatar
+ 3
Could you show the part of the code where you take input and the array, because like this is hard to say..
4th Jan 2019, 8:13 AM
Sekiro
Sekiro - avatar