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

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

python - How to remove the Xframe Options header in django? -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -