Consider an example:
The value of “a” should not be evaluated as NULL.
pwd1- password from database
pwd2- password entered by user
Returns NULL if “pwd1” is not found in database.
When I tried to use this code line, it gave Null pointer exception. The value of “pwd2” cannot be NULL as it is validated for not null before this code. When “pwd1” is searched in database to check if it matches “pwd2” and no value exists, it returns NULL.
So, change it to pwd2.equals(pwd1)
” match ” is a constant so it cannot be Null. But “Str” if doesnt contain any value can give a Null value. So, better change to ‘match’.equals(Str)