Question: how to avoid npe in java?
Answer: 1) Call equals() and equalsIgnoreCase() method on known String literal rather unknown object. 2) Prefer valueOf() over toString() where both return same result. 5) Use of annotation @NotNull and @Nullable.