Java / Using String
How to avoid NullPointerException when comparing two Strings in Java?
When a string is compared to null, equals return false and doesn't throw NullPointerException. So when a string constant is compared invoke equals on the string constant as it avoids NullPointerException.
"SomeStringLiteral".equals(str)
More Related questions...