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
URVASHIURVASHI 

List<list<String> Apex Salesforce

Hi any anyone explain me the concept of 2 array using list<list<String>>.

How to access individual elements of both the list.

 

if suppose i have

 List<List<String>> HeaderDataC = new List<List<String>>();
    List<String> list1 = new List<String>();
    List<String> list2 = new List<String>();

list1.add('val1');

list1.add('val2');

list2.add('1');

list2.add('2');

 

    HeaderDataC.add(list1);
    HeaderDataC.add(list2);

 

but here what represents row data n what represents column data.

and if suppose i wana insert value in specific row of specific column,how do i achive it?

like HeaderDataC[2][3]?

 

Thanks in advance.

Best Answer chosen by Admin (Salesforce Developers) 

All Answers

Avidev9Avidev9
This was selected as the best answer
Kishore DasariKishore Dasari
ListOfListHere is List<List<String>>

List<String> OneListOfAllStrings = new List<String>();

For(List<String> IndividualList : ListOfListHere){
    OneListOfAllStrings.addAll(IndividualList);
}


Iterate each list from ListOfListHere and add to the list to which you are trying to copy values using for loop.