Why are all of the nodes that I add to different lists ends up in one list? [duplicate]

Solution 1:

your _head variable is a static property of the RectList class . static members have the same value in all occurrences of the class. so when you do rL1.addRect(r1); rL2 also get r1 as it's head. then you do rL2.addrect(r2) and it adds r2 to the reference of the head, which is the same head of both objects (because the head is the static variable).

you can just remove the static keyword and it should do the trick.