I have a method to create a list of objects of class
public List initProducts(){
List product = new ArrayList();
product
is reference to List
object.
and List/ArrayList
has no methosd named getId()
.
You have written getId()
method for Prodct
class , so you can call this method using ref to Product
class object.
If you want to get any product object form list use get(int index)
method of ArrayList
.
eg.
Product prod = product.get(0);
String id= prod.getId();