Unique way to check for Nulls


While implemeting a new feature in our code base I came across a uniue piece of code for checking a string variable for null. Here it is:

if (variableName.equals( null ) ) // type of variableName was String   
{   
    // do something   
}  

 Note: Never try this in your code, this will never work.

Advertisements
Unique way to check for Nulls

2 thoughts on “Unique way to check for Nulls

  1. Little_bunny says:

    This will certainly work.In some situations element of a vector is checked in this way and it works,this is my personal experience.(more specifically when variablename==null is failed) .

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s