cant find the error , please help.
im getting this error: Code:
java.lang.ExceptionInInitializerError
Caused by: java.lang.NullPointerException
at Map.<init>(Map.java:21)
and i cant find the errors origen.
heres the code:
Code:
import java.util.List;
public class Map {
public
Entity GLOBAL_ENTITY = new Entity();
List<Entity> ents;
char[][] map = new char[10][10];
private
int x,y,i;
public Map()
{
for(x = 0; x < 10; x++)
{
for(y = 0; y < 10; y++)
{
map[x][y] = '*';
}
}
ents.add(GLOBAL_ENTITY.add());
}
public void DrawMap(List<Entity> el)
{
for(i = 0; i < el.size();i++)
{
for(x = 0; x < 10; x++)
{
for(y = 0; y < 10; y++)
{
map[x][y] = el.get(i).draw_char;
}
}
}
}
}
Code:
//import java.util.*;
public class Entity {
public
Vector vector = new Vector();
static int count;
int id;
final char draw_char = 'e';
public void Entitty()
{
count++;
id = count;
}
public void MoveDir(int ar)
{
switch(ar)
{
case 0:
vector.x -=1;
break;
case 1:
vector.y -=1;
break;
case 2:
vector.x +=1;
break;
case 3:
vector.y +=1;
break;
default:
System.out.printf("Illigal argument. use 0 , 1, 2 , 3");
break;
}
}
public Entity add()
{
Entity re = new Entity();
return(re);
}
}