Hi, I have a problem with String objects that were set to null. I have a String object token, and token.toString() returns null. But when I make equivalence test with (token==null) and (token.equals(null), both returned false. How can I test if a String object to be null? Thanks!
If a String object is null, it can be compared to null. In your example, (token == null) will return true if String is null and token.toString() will throw a NullPointerException. What you have is a String object which has a value of "null" try token.equals("null") Hope this helps