If I try to do a .equals() on a null string in java, a null pointer exception will be thrown. I am wondering, if I am trying to compare if a string is equal to
.equals()
Nope, it's usually done to avoid NPE. However, I usually prefer to do explicit check for null.