I have a TreeSet that will store several objects of a "Products" class, this class has 3 attributes:
int codProduct; String descProduct; float precoProduct;
After storing some "Product" objects in this TreeSet, I need to print the contents of each of them. For this, I made this method:
public String imprimeLista(){
Iterator<Produto> i = lProdutos.iterator();
while (i.hasNext()){
System.out.println(i.next() + " ");
}
return("");
}
I've registered 2 products to test, and what it prints is:
proj.catalogo.Produto@28d93b30
proj.catalogo.Produto@1b6d3586
How can I get it to print codProduct, Product, and preProduct?