As everyone says, you will need to check (string! = Null), in the objects that you are testing the memory pointer.
since each object is identified by a pointer to memory, you must check your object for a null pointer before testing anything else, therefore:
(string! = null &! string.equals ("")) good
(! string.equals ("") && string! = null) can give you a nullpointer exception.
if you don't need trailing spaces, you can always use trim () before equals () so "and" "gives you the same result
source share