Java Jirawat
Jirawat Uttayaya Tech Notes
2013-01-13
Null safe string equals
Instead of
if ( str != null && str.equals("TheString") )
use
if ( "TheString".equals(str) )
The second form is more concise and will return false if str is null.
No comments:
Post a Comment
‹
›
Home
View web version
No comments:
Post a Comment