java - I pass a string -> NullPointerException -
this question has answer here:
- what nullpointerexception, , how fix it? 12 answers
i writing adnroid app, , when pass string @ point, nullpointer ...does know why?
code
elements titles = doc.select("h3 a"); string[] titlelist = null; bitmap[] bitmaps = null; outputtext = ""; int = 0; (element title : titles) { titlelist[i] = title.text(); // <--- here comes nullpointer = + 1; }
log:
08-18 17:17:54.522 26470-26470/de.m4lik.somesampleapp e/androidruntime﹕ fatal exception: main process: de.m4lik.somesampleapp, pid: 26470 java.lang.nullpointerexception @ de.m4lik.somesampleapp.mainactivity$thetask.onpostexecute(mainactivity.java:95) @ de.m4lik.somesampleapp.mainactivity$thetask.onpostexecute(mainactivity.java:68) @ android.os.asynctask.finish(asynctask.java:632) @ android.os.asynctask.access$600(asynctask.java:177) @ android.os.asynctask$internalhandler.handlemessage(asynctask.java:645) ...
the doc.select part jsoup code select headings website.
titlelist
not initialized.
you need initialize prior assigning strings :
string[] titlelist = new string[titles.size()]; // assuming elements has size() method
Comments
Post a Comment