The most common way of checking for equality of a string is as below


String str = "Santhosh";
if(str!=null && str.equals("Santhosh"))
{
//Code here...
}
str!=null is checked to make sure we don't encounter the NullPointerException. These two conditions can be simplified into a single condition as below

String str = "Santhosh";
if("Santhosh".equals(str))
{
//Code here...
}

As you know, we often have to check string reference is not null and it is not a blank while working with strings. The most common way of doing this check is as below


String str = null;
if(str!=null && !str.equals(""))
{
//Code here...
}

However, if you would like to execute a code block in all the scenarios except when string has a blank value i.e.; it is expected to have null values - implementation will be as below


String str = null;
if(str==null || !str.equals(""))
{
//Code here...
}

The above second implementation can be simplified as below


String str = null;
if(!"".equals(str)) //Note, if you check like !str.equals(""), null pointer exception will be thrown when str is null
{
//Code here...
}
FYI - as per the Java API, equals method returns true if and only if the argument value is not null and has the same sequence of characters.