Cannot understand this behaviour of java when adding a list to a list of lists.

https://leetcode.com/problems/subsets/submissions/1236349921
this is the leetcode ques i was solving
as you can see the ans list which is supposed to be a subset of the set is being formed and is printed in the stdout just before it was added to the fin global string which is ultimately returned as the answer.
on further debugging its adding the current string n number of times where n is the array index of the power set array
so in the last iteration its adding a null set n(8) times.
But when i pass a clone of the list in function call, the program works as intended
Any explanation?
Was this page helpful?
Cannot understand this behaviour of java when adding a list to a list of lists. - Java Community | Help. Code. Learn.