import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
import vetores.Aluno;
public class Main {
public static void main(String[] args) {
// CRIAÇÃO DOS OBJETOS
Atendente c1 = new Atendente("Joao", 1000);
Atendente c2 = new Atendente("Jose", 1000);
Atendente c3 = new Atendente("Maria", 800);
Atendente c4 = new Atendente("Pedro", 1900);
Atendente c5 = new Atendente("Antonio", 2100);
// CRIAÇÃO DA LISTA
Collection<Atendente> lista = new TreeSet<Atendente>();
// ADD NA LISTA
lista.add(c1); lista.add(c2); lista.add(c3); lista.add(c4); lista.add(c5);
// CRIACAO DO ITERATOR
Iterator<Atendente> it = lista.iterator();
// USANDO O ITERATOR PRA CHECAR SE HÁ PROXIMO
while (it.hasNext()) {
// PASSANDO A UM OBJ DO TIPO ATENDENTE AS AÇÕES DO ITERATORFF
Atendente e = (Atendente) it.next();
// IMPRIMINDO
if(e.nome.equals("Joao")) { //PQ NÃO ESTÁ REMOVENDO? COMO FAÇO? TENHO QUE SOBRESCREVER O METODO EQUALS DA MINHA CLASSE ATENDENTE?
it.remove();
}
System.out.println(e.nome + " - " + e.salario);
}
}
}
A duvida é,
Pq não estou conseguindo remover o objeto que possui o nome “Joao”?
Abraçossss