java null pointer exception with static array
问题 I got a null pointer exception when accessing a static array from a static member method. The exception is thrown when i call setData(x, y, z) from a thread. When I debugged it I found out data[0] is null when i try to write to it. I just don't understand how it can be null public class dataContainer { private static final short nrOfDataElements = ids.total_ids; private static regularDataElement[] data = new regularDataElement[nrOfDataElements]; public static synchronized void getData(final