I'm making a method of adding Users, and only one thing is not working, the function that:
"You will not be allowed to add friends with the same mobile number."
Then you need to check the users already added, to see if they do not have a cell number equal to the one added. It's adding, but it's also adding users with the same cell number. And could not add if the number were equal
publicvoidAdicionaAmigo(Usuariousr){booleanexisteEsteNum=false;if(ListadeAmigos==null||ListadeAmigos.length==0){for(inti=0;i<ListadeAmigos.length;i++){if(ListadeAmigos[i].getCel()==usr.getCel()){existeEsteNum=true;System.out.println("Já existe um usuário cadastrado com esse número de celular");
break;
}
}
}
if(!existeEsteNum){
if(qtdeAmigos < ListadeAmigos.length)
{
ListadeAmigos[qtdeAmigos++] = usr;
System.out.println ("Usuario adicionado com sucesso!");
} else {
System.out.println ("A lista está cheia");
}
}
}