+ 2

There is two arraylist named ate and killed

And grandmother object and wolf object. I understand ate.add(grandmother); Which is ....add the grandmother object to the arraylist ate. But i dont understand this... wolf.ate.add(grandmother) Please help me understand it. Thank you. https://code.sololearn.com/cy3yQTKHZKVf/?ref=app

24th Jan 2022, 3:14 PM
stephen haokip
stephen haokip - avatar
3 Answers
0
wolf.ate.add(grandmother); wolf.ate.add(hood); // ate.add(hood); As I told you, you are created objects of classes wolf,........... And adding other objects to list ate through wolf object. You can see lists are created in StoryItem class which is defined abstract and wolf class is it's concrete (defined) class. And see my comment statement raise error as cannot find symbol 'ate' but you can use same in Wolf and StoryItem classes..
24th Jan 2022, 3:39 PM
Jayakrishna 🇼🇳
+ 1
ate object is created in class of wolf, and by wolf object you are accesing ate list and adding grandmother object. . ate.add(grandmother) works as you expected and it is done in which list is created but wolf.ate.add(grandmother) is may be from other classes or from main..
24th Jan 2022, 3:21 PM
Jayakrishna 🇼🇳
+ 1
Jayakrishna🇼🇳 and Ipang i have added the link to the original code plis have a look
24th Jan 2022, 3:27 PM
stephen haokip
stephen haokip - avatar