I am attempting to assign a value to an array object like this:
public class Players {
String Name;
}
Players[] player = new Players[10];
String name = Mike;
player[1].Name = name;
I am getting a NullPointerException and am not sure why. What could be causing this?
This is because creating a new array does not create individual objects inside the array; you should be creating them separately, e.g. in a loop.