用代码
package items;
public class itemtest {
static itemobject[] item = new items[10];
{
items[0] = new Toy("Example ID","Example Desc");
items[1] = new Toy("Second Example ID", " Second Example Desc");
}
public static void main(String[] args)
{
String tid = items[0].exampleiD;
System.out.print(tid);
}
}
我得到错误:
Exception in thread "main" java.lang.NullPointerException at items.itemtest.main(itemtest.java:17)
在代码行上:String tid = item[0].exampleID;
抱歉,我对 java 很陌生,有人能解释一下我做错了什么吗?