i have this code
if (table[(position + i * i) % capacidad] == null) {
table[(position + i * i) % capacidad].setKey(clave);
table[(position + i * i) % capacidad].setValue(valor);
check = true;
}
And have this output about lane 2.
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "com.mycompany.tablahash.Entrada.setKey(Object)" because "this.table[...]" is null
at com.mycompany.tablahash.TablaHash.put(TablaHash.java:49)
at com.mycompany.tablahash.ClienteTablaHash.main(ClienteTablaHash.java:19)
I checked with the debug and the dir((position + i * i) % capacidad) is 0. This is the constructor
protected Entrada[] table;
public TablaHash(int capacidad, boolean metodo) {
this.capacidad = capacidad;
this.metodoDeColisiones = metodo;
this.table= new Entrada [capacidad];
}
Capacity is settled at 100