java - Why does a non-empty List throw a Null Pointer Exception? -
i have list array 'details'.
list<historydetails> details
where historydetails object containing strings.
when check size gives me positive value.
details.size()
but when try access element throws null pointer exception.
details.get(0).getfirstelement(); attempt invoke virtual method 'java.lang.string com.historydetails.getfirstelement()' on null object reference
i invoking element @ next line check size. hence, nothing should reset. wrong?
a list details
having many items can have first item null object. before using item check null.
if(details.get(0)!=null){ details.get(0).getfirstelement(); }
Comments
Post a Comment