I'm having a problem with the function remove() from ArrayList. I'll try to be as brief as possible. I have an ArrayList, Posicao is another class that I created, and I put some Objects in the Array. The problem is that when I print all the value in the ArrayList I get what a expect, but when I try to use remove(object) or lastIndexOf(value) it doesn't work. Remove() doesn't remove anything and lastIndexOf(), or even indexOf(), I get an error saying that the object that I requested is not in the Array. I double checked and the Object is in fact there. Is there anything that I'm doing wrong? The part of my code that I'm getting the problem. If there is something else that I need to post just ask. (=
System.out.println("BEGIN - Print beforeremove:" + tabuleiro0.posicoesLivres.contains(pos));
for(int i = 0 ; i < tabuleiro0.posicoesLivres.size() ; i++)
System.out.println(((Posicao)tabuleiro0.posicoesLivres.get(i)).x + " " + ((Posicao)tabuleiro0.posicoesLivres.get(i)).y);
System.out.println("END - Print before remove :");
tabuleiro0.posicoesLivres.remove(pos);
System.out.println("BEGIN - Print after remove:" + tabuleiro0.posicoesLivres.contains(pos));
for(int i = 0 ; i < tabuleiro0.posicoesLivres.size() ; i++)
System.out.println(((Posicao)tabuleiro0.posicoesLivres.get(i)).x + " " + ((Posicao)tabuleiro0.posicoesLivres.get(i)).y);
System.out.println("END - Print after remove :");
Thanks already for the patience (=