Y
Y
yarovoi_ivan2016-05-27 16:36:57
Java
yarovoi_ivan, 2016-05-27 16:36:57

How to get rid of java.lang.NullPointerException error?

The bottom line is this

ArrayList<EventCalendar> event_calendar_list = null;
        for (int i = 0; i < tvSeries.size(); i++) {
            System.out.println(tvSeries.get(i).getKinopoiskID());

            ArrayList<Series> series = null;
            try {
                series = ld.loadMyMuviCalendar(tvSeries.get(i).getKinopoiskID().toString());
            } catch (IOException e) {
                e.printStackTrace();
            } catch (JSONException e) {
                e.printStackTrace();
            }

            for (int ii = 0; ii < series.size(); ii++) {
                EventCalendar ec = new EventCalendar();
                ec.setDate(series.get(ii).getDate());
                ec.setMuvi_obj(tvSeries.get(i));
                ec.setSeri_obj(series.get(ii));
                System.out.println(ec);
//
                event_calendar_list.add(ec);
            }

The data all comes and the run through the array goes as it should, I can even display this data in the console, but when I try to add it to the event_calendar_list, I get the error java.lang.NullPointerException

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg Gamega, 2016-05-27
@gadfi

umm so it's null
replace
on the

ArrayList<EventCalendar> event_calendar_list = new ArrayList<EventCalendar> () ;

#
#algooptimize #bottize, 2016-05-27
@user004

The question is so well formulated that it contains the answer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question