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
AnjaneyluAnjaneylu 

One-Dimensional Lists and Two Dimensional lists

what is the difference between the  One-Dimensional Lists and Two Dimensional lists .
if possible give one simple example..
Thanking you in advance..
 
Shashikant SharmaShashikant Sharma
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

One-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
padmapadma
 hi sharma,
i can' t understand the  second example
integer i= listint.get(1).get(0);
here i will be 3 are you telling but how can explain
Shashikant SharmaShashikant Sharma
Hi Padma,


List<List<Integer>> listOfListInt = new List<Integer> { {0, 1, 2, 3}, {3, 2, 1, 0}, {3, 5, 6, 1}, {3, 8, 3, 4} };

Read this in two statements 

List<Integer> listint = listOfListInt.get(1); // this will give {3, 2, 1, 0}
Integer i= listint.get(0); // this will give 3

so this could be written in one statement as

Integer i= listOfListInt.get(1).get(0); 

Please mark this as answer so others could be helped form it.
 
padmapadma
Thank you sharma
i will understand.