In my World, I have created a new class - Player like this:
Then I make an array.
But when I try to print it out like this:
I get a null pointer exception. Unless I have made a obvious error with it, I have no idea at all what is wrong
Any ideas - I'd rather not make two separate arrays!
public class Player
{
Player()
{
name="Player";
chp=0;
}
String name;
int chp;
}Player[] save= new Player[3];
for(int i=0;i<=2;i++){
System.out.println(save[1].name+";"+save[1].chp);
}
