01 nums binary-long occurs 3 values 1, 2, 3. *> Can also do: set content of nums to (1, 2, 3) *> 5 is the size of the array 01 names string occurs 5. *> Can also do: 01 names string occurs any. set size of names to 5 set names(1) to "Rod" *> first element indexed as 1 set names(6) to "Jane" *> throws System.IndexOutOfRangeException *> COBOL cannot resize an array - use copy 01 names2 string occurs 7. invoke type Array::Copy(names, names2, names::Length) *> or: invoke names::CopyTo(names2, 0) *> or: invoke type Array::Resize(names, 7) 01 twoD float-short occurs any, any. set size of twoD to rows, cols 01 jagged binary-long occurs any, occurs any. set size of jagged to 3 set size of jagged(1) to 5 set jagged(1 5) to 5
Portions of these examples were produced by Dr. Frank McCown, Harding University Computer Science Dept, and are licensed under a Creative Commons License.