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
James L.James L. 

For "each" loop follows the order as for (integer i=0; i< xx, i++) ?

Integer[] arr = new Integer[] {3, 31,6,9};

 

loop 1

for (Integer tmp: arr) {

 

}

 

lopp2

for (Integer i=0; i < arr.size();i++) {

    Integer tmp = arr[i]

}

 

Will those 2 loop follow the same order when iterating the array ?

 

 

Best Answer chosen by Admin (Salesforce Developers) 
logontokartiklogontokartik

Yes. when you define an array in that format, its nothing but a list collection, which is ordered.