Why does a non-empty List throw a Null Pointer Exception?

[postlink] https://the-best-way-of-life-is-islam.blogspot.com/2015/07/why-does-non-empty-list-throw-null.html [/postlink]

I have an List array 'details'.

List<HistoryDetails> details

where HistoryDetails is an object containing strings.

When I check the size it gives me a positive value.

details.size()

But when I try to access an element it throws a null pointer exception.

details.get(0).getFirstElement();


Attempt to invoke virtual method 'java.lang.String com.HistoryDetails.getFirstElement()' on a null object reference

I am invoking the element at the very next line to where I check the size. Hence, nothing should be reset. What could be wrong?

اذا أعجبك الموضوع ساهم في نشره :

Enregistrer un commentaire

 
حقوق النشر: Published by | Template Created by | القناة على اليوتيب
copyright © 2014. The Best Way Of Life Is Islam -يمكن نقل كل ما هو موجود في موقع الرحمة تيوب
القرآن الكريم و الأحاديث النبوية أناشيد و دروس اسلامية منوعة موقع الفيديوهات الاسلامية
تطوير و تعريب مدونة ثعلوب