Hello guys,
Is it possible to check if something is equal to null? And receive a boolean answer? I'm pretty confused with this one, why I can have a value of null for an object and then right after can't I do boolean stuff on it?
please check what I did:
String userConfirmation = users.get(0).getConfirmationEmail();
---> It is an object that Hibernate gave me. It is a MySQL field which started with a null value. hibernate created this mysql field, therefore, its initial value is set (?) to null.
logger.info("confirmation email = " + userConfirmation);
logger.info("confirmation email = " + userConfirmation.equals(null));
logger.info("confirmation email = " + userConfirmation.equals(""));
logger.info("confirmation email = " + userConfirmation.equals("OK"));
----> What I received with the original field set to null:
1. mysql field equals null:
confirmation email = null
confirmation email = logic error
---> field set to empty string
2. mysql field equals empty string:
confirmation email =
confirmation email = false
confirmation email = true
confirmation email = false
---> field set to OK
3. mysql field equals OK:
confirmation email = OK
confirmation email = false
confirmation email = false
confirmation email = true
I know that I can update the field by hand, setting it all to empty string in mysql. But I want to understand why "equals(null)" doesn't works..
Thanks!
p.s. is this suited for this forum? have just read that "questions of any difficulty should be posted in the intermediate forum".. Moderators, please move my post if you think it is no suited for this forum.
thanks!
[ April 05, 2006: Message edited by: Fabio Fonseca ]