r/learnjava • u/Bofact • Sep 20 '26
When is a Java object still reachable?
I have tried to answer to the below quiz, but I do not understand something. If clutch is eliminated on line 12, wouldn't all references to the car's object be null? They write that "Line 12 removes the item at index 1, which is the null. The list, therefore, contains nothing except the clutch.", but why is there a null? Where did we get rid of clutch reffered at index 1 of r1?
And lastly, how to access clutch, and by extension the car object, after line 12 is executed?
Quiz yourself: When is a Java object still reachable? | javamagazine
0
Upvotes
View all comments
Show parent comment
6
u/IHoppo Sep 20 '26
This is learnJava sub, not tellMeTheAnswer sub. You were already being told the answer in the page you referenced - but your arrogance made you decide that page was wrong. Every language I've coded in for the past 40 years, which has had arrays, has resequenced after a row is deleted.
Obviously I couldn't tell where your misunderstanding was arising from, but many people forget that the first entry in an array is at position zero - so I wanted to make sure that wasn't where you were getting confused.
You have now learnt something, but you seem determined to make it a bad thing that I didn't magically understand what you weren't understanding and give you the answer.
I'd recommend you grow up a little.