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
Kalpana WankhedeKalpana Wankhede 

Hello, Difference between one dimensional and two dimensional list?

Best Answer chosen by Kalpana Wankhede
AnkaiahAnkaiah (Salesforce Developers) 
Hi Kalpana,

A one-dimensional array stores a single list of various elements having a similar data type.
ex: List<String> Mnth = new List<String>();  

The two-dimensional array can be defined as an array of arrays. or a list of various lists, or an array of various one-dimensional arrays. It represents multiple data items in the form of a list.

ex: List<List<String>> Mnth = new List<Iist<String>>();  

If this helps, Please mark it as best answer.

Thanks!!

All Answers

AnkaiahAnkaiah (Salesforce Developers) 
Hi Kalpana,

A one-dimensional array stores a single list of various elements having a similar data type.
ex: List<String> Mnth = new List<String>();  

The two-dimensional array can be defined as an array of arrays. or a list of various lists, or an array of various one-dimensional arrays. It represents multiple data items in the form of a list.

ex: List<List<String>> Mnth = new List<Iist<String>>();  

If this helps, Please mark it as best answer.

Thanks!!
This was selected as the best answer
mukesh guptamukesh gupta
Hi Kalpana,

One-Dimensional Lists - Is when items in the list are linear and you could access them with one index only.
Example - List<Integer> listint = new List<Integer>{0, 1, 2, 3 };

You could access item like
Integer i = listint.get(0); // which returns integer from 0th index 
here i will be 0

Two-Dimensional Lists - Is when items in the list are linear and you could access them with more then one index.
Example - List<List<Integer>> listOdListInt = new List<Integer> { {0, 1, 2, 3}, {3, 2, 1, 0}, {3, 5, 6, 1}, {3, 8, 3, 4} };

Integer i = listint.get(1).get(0); // which returns integer from 0th index of 1st index list 
here i will be 3

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh 

 
jonson pricesjonson prices
Portillo’s purpose to kick off this Tell Portillo’s Survey  (https://surveyz.onl/portillos-survey/)is to discover what customers ‘ opinions are about their shopping experience. The survey can be completed online to help you make the most of your time.