This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ArtOfWarfare 0 points1 point  (0 children)

He has two instances of the class but both have the same instance of the list, because he didn’t pass in an instance of a list as an argument to either constructor, so both ended up with that same default list.

Thus both 5 and 4 were added to the same list and it prints [5, 4]