function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sagar gusani 16sagar gusani 16 

unexpected output in nested list

Hi All,

I trying to print nested list using system.debug().
Output in log : ((1,2,5),(already output))
expected      : ((1,2,5),(1,2,5))

when i iterate to list i am getting expected outputs. 
just want to know why it is showing "already output" in debug log?

User-added image
dsksatishdsksatish
I am assuming (already output) comes up when the same object is being debugged (printed) twice in the same statement. In your case, the list 'inside' is being added to the parent list 'test' twice and is printed.
In any case, you can iterate through the list to have the individual values
List<Integer> inside = new List<Integer>{1,2};
List<List<Integer>> test = new List<List<Integer>>();
test.add(inside);
inside.add(5);
test.add(inside);
System.debug(test[1]);
System.debug(test);
for(List<Integer> lst : test){
    System.debug(lst);
}

Thanks,
Satish Kumar