Good afternoon!
I'm doing a hash table and for this I'm trying to create an AVL Tree vector. The problem is that when I try to insert a value into any tree of this vector it is giving the "NullPointerException" exception. Could someone tell me where I'm wrong?
I am very grateful.
public class Hashing {
ArvoreAvl[] lAVL;
int mod;
public Hashing(int tamanho){
lAVL = new ArvoreAvl[tamanho];
mod = tamanho;
}
public void inserir(int valor){
int rest = valor % mod;
for(int x = 1; x < lAVL.length; x++){
if(x == rest){
// Está dando java.lang.NullPointerException na linha abaixo
lAVL[x].inserir(valor);
}
}
}
public void remover(int valor){
int rest = valor % mod;
for(int x = 0; x < mod; x++){
if(x == rest){
lAVL[x].remover(valor);
}
}
}
public void imprimir(){
for(int x = 0; x < lAVL.length; x++){
lAVL[x].inorder();
System.out.println();
}
}