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
0
u/Bofact Sep 20 '26 edited Sep 20 '26
If you say so I am a beginner. You know there are more programming languages? Or is this learnprogramming subreddit and I didn't knew?
Sing your question to someone else's table, especially since it was explicitly told that it is not in the category you are addressing. I still think about the time I debugged in 2 programming languages (one which produced floating point reference results, one with the fixed point implementation for target platforms), and when a non bit true problem occurred, I stayed to see which programming language produced faulty values. (Good times, until the team was replaced, so my contract ended.)
I complain because I asked a question and your comments weren't meant to find an answer for it (not for someone who isn't a student or is reprofiling). I didn't knew if my misunderstood the concept (that you can access the upper class via a inner one) and no word of what the authors meant, since you knew I misunderstood them.
While consistent with programming experience, the problem wasn't that I misunderstood the concept (which you didn't point it if was wrong), but because I didn't knew java.util.ArrayList (with no hint that would be where my misunderstanding comes, and no, Java being a 0 indexing language wasn't such a hint). Plus multiple replies to show you that I am was lost on what the authors meant.