I'm trying to create a little project of mine, and I created an array of an element. It however creates a NullPointerException when executed.
package main;
import java.io.*;
import java.util.Arrays;
public class item implements java.io.Serializable{
public String Name;
public String Description;
public float[] Stat;
public static void main(String [] args)
{
item Items[] = new item[1000];
Items[0].Name = "item1";
Items[1].Name = "item2";
try
{
FileOutputStream fileOut = new FileOutputStream("../items.config");
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(Items[1]);
out.writeObject(Items[0]);
out.close();
fileOut.close();
}catch(IOException i)
{
i.printStackTrace();
}
}
}
How do I initialize the element to remove the NullPointerException It occurs on lines 13 & 14