That story is very very yhmm crazy.
But what happen here with wolf, wilk.zjadl.add(babcia)
zjadl.add(babcia) is added babcia to ArrayList zjadl,
but wolf before .zjadl , what doing?
Calling a wolf object adds granny to "arraylist" at the same time?
Can someone explain to me what happen here.
Rozwiązane
Komentarze (3)
- Popularne
- Najnowsze
- Najstarsze
Musisz się zalogować, aby dodać komentarz
Lisa
13 sierpnia 2021, 05:50rozwiązanie
Craaaazyyyy 😜🤪... that's where I'm feeling at home, hahahahawuahhh
lets start with eg. the Wolf class. It extends StoryItem. Cause it extends StoryItem you can access the lists defined in the StoryItem abstract class using a Wolf object. And as luck would have it CG has already created such a static object for us... the wolf. With the above info you now know that wolf.ate is referencing a list (the list is a field, an instance variable... so each object has its own).
When wolf.ate is referencing the list and the list takes StoryItems then you could put objects of every object derived of StoryItem into that list using the well know add method.
Now we have wolf.ate.add() and we now just need to push the grandma object into the wolfs mouth:
wold.ate.add(grandmother);
yeah, yeah... that's crazy... I'm dancing like little red through the woods 🤪😜
+2
Robert
13 sierpnia 2021, 11:48
Now I feel like a grandma eating by wolf java 😉
0
Lisa
13 sierpnia 2021, 13:29
I think this task is just to see some weird references and to get used to them. So don't worry, don't worry 😜🤪 I aleady do, crazy, crazy
0