I have an array of classes, in this case ProductsA. I am going through it with the for each,
Products []productsA = new Products[3];
productsA[0] = new Products("perfum",50);
productsA[1] = new Perishable("tv",400,2);
productsA[2] = new Nonperishable("phone",
200,"electrodomestico");
for(Products i:productsA) {
int totalPrice = i.getPrice()*5;
array = {totalPrice};
that last line marks an error (Array constants can only be initializers). I want that in each return to save that result in the array to later add it and go through it. By the way, I have it globally.
int array[];
also try with the normal for loop and mark more errors I could only with this
You need to know the position in which you will store the totalPrice, it could be something like this: