Skip to main content
added 17 characters in body
Source Link
Ousmane D.
  • 56.6k
  • 8
  • 101
  • 134

I'm writing a simple GUI program where I have to input login and password for user and then check if he is in database (my Hashmap). That's where i have problem. I checked if login is correct by containsKey and checked for password by containsValue. The problem is, that if in example I have 2 users:

login: user1 password: example login: user2 password: programing

login: user1 password: example login: user2 password: programing 

If I will put login user1as user1 in my JTextFieldJTextField and password programing"programing", the program says, that it's correct.

That's where I have a problem. How to check forthe password for exact login, which is key?

Would be very thankfullthankful for any clues or solutions :)

I'm writing a simple GUI program where I have to input login and password for user and then check if he is in database (my Hashmap). That's where i have problem. I checked if login is correct by containsKey and checked for password by containsValue. The problem is, that if in example I have 2 users:

login: user1 password: example login: user2 password: programing

If I will put login user1 in my JTextField and password programing, program says, that it's correct.

That's where I have problem. How to check for password for exact login, which is key?

Would be very thankfull for any clues or solutions :)

I'm writing a simple GUI program where I have to input login and password for user and then check if he is in database (my Hashmap). That's where i have problem. I checked if login is correct by containsKey and checked for password by containsValue. The problem is, that if in example I have 2 users:

login: user1 password: example login: user2 password: programing 

If I put login as user1 in my JTextField and password "programing", the program says, that it's correct.

That's where I have a problem. How to check the password for exact login, which is key?

Would be very thankful for any clues or solutions :)

Source Link

How to check if value is correct for key in HashMap in Java

I'm writing a simple GUI program where I have to input login and password for user and then check if he is in database (my Hashmap). That's where i have problem. I checked if login is correct by containsKey and checked for password by containsValue. The problem is, that if in example I have 2 users:

login: user1 password: example login: user2 password: programing

If I will put login user1 in my JTextField and password programing, program says, that it's correct.

That's where I have problem. How to check for password for exact login, which is key?

Would be very thankfull for any clues or solutions :)