Handling the string "null" as an Object in Java -
i have tweets stored in mongodb database, , pulling them out analysis.
in instance, i'm looking @ hashtags associated tweet, , using next code:
basicdblist hts = (basicdblist)obj.get(constants.hashtags_str); if (!hts.isempty()) tb.sethashtags(hts.toarray(new string[0])); this works perfectly... until came across tweet used word "null" hashtag.
in case, hts array is:
[ null ] the hashtags stored in treeset internally, , insert fails on compare. don't want discard hashtag doing comparing null - there improve workaround?
the string literal "null" stored in database. problem occurs when basicdblist reads out object, , object converted string. string becomes null string, instead of string "null". want understand how info interpreted correctly, such
tb.sethashtags() results in tb having hashtag "null" associated it, instead of error beingness thrown.
verify whether list (basicdblist)hts contains null values.
the method toarray inherited arraylist, may homecoming array containing null values.
have @ http://docs.oracle.com/javase/1.5.0/docs/api/java/util/arraylist.html#toarray(t%5b%5d)
java string object null
No comments:
Post a Comment