I have this method that adds things to the list:
public Pedido adicionarPedido(int quantidade, String nome){
lista.add(new Item(quantidade, nome ));
return this;
}
And instantiated in this class the attributes in the list:
List<Item> lista = new ArrayList<Item>();
I'm asking you to display in the toString method the list data plus the person's name:
public Pedido ToString() {
mensagem = "Pedido [lista=" + lista.get(0) + lista.get(1) + ", cliente=" + cliente.getNome() + "]";
return this;
}
The problem is that the console is printing like this:
Pedido [lista=teste.Item@15db9742 teste.Item@6d06d69c, cliente=Aline Gonzaga]
But I want the items in the list to be printed.
How can I do this?