Когда я запускаю этот код,
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
class Posting
{
String title;
}
public class Test
{
Posting[] dew()
{
Posting[] p = new Posting[100];
for(int i = 0; i <p.length; i++)
{
p[i].title = "this is " + i;
}
return p;
}
public static void main(String args[])
{
Test t = new Test();
Posting[] out = t.dew();
for(int i = 0; i < out.length; i ++)
{
System.out.println(out[i].title);
}
}
}
Я получаю эту ошибку, запускаю:
Exception in thread "main" java.lang.NullPointerException
at mistAcademic.javaProject.newsBot.core.Test.dew(Test.java:20)
at mistAcademic.javaProject.newsBot.core.Test.main(Test.java:29)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
Не могли бы вы иметь какие-либо идеи?