Always write string before the string variable while using equals function.
example:
if("".equals(variable))
rather than
if(variable.equals(""))
Here if the string variable is null then it will throw Null Pointer Exception.
So for best practice always write string before the string variable while using equals function.
example:
if("".equals(variable))
rather than
if(variable.equals(""))
Here if the string variable is null then it will throw Null Pointer Exception.
So for best practice always write string before the string variable while using equals function.
0 comments:
Post a Comment