Array of objects in X++ Programming Language
☰Fullscreen
Table of Content:
Array of objects
Array arr = new Array(Types::String); arr.value(1, "K"); arr.value(2, "U"); arr.value(3, "L"); arr.value(1, "U"); for (int i = 1; i <= arr.lastIndex(); i++) { str val = arr.value(i); }
internal final class ArrayExample { /// /// Class entry point. The system will call this method when a designated menu /// is selected or when execution starts and this class is set as the startup class. /// /// The specified arguments. public static void main(Args _args) { // Declare and instantiate an array Array intArray = new Array(Types::Integer); // Assign values to array elements intArray.value(1, 12); intArray.value(2, 13); intArray.value(3, 14); intArray.value(4, 15); intArray.value(5, 16); // Access and display array elements info(strFmt("Element %1: ", intArray.value(1))); info(strFmt("Element %1: ", intArray.value(2))); info(strFmt("Element %1: ", intArray.value(3))); info(strFmt("Element %1: ", intArray.value(4))); info(strFmt("Element %1: ", intArray.value(5))); } }
internal final class ArrayExample { /// /// Class entry point. The system will call this method when a designated menu /// is selected or when execution starts and this class is set as the startup class. /// /// The specified arguments. public static void main(Args _args) { // Declare and instantiate an array Array intArray = new Array(Types::Integer); // Assign values to array elements intArray.value(1, 12); intArray.value(2, 13); intArray.value(3, 14); intArray.value(4, 15); intArray.value(5, 16); // Access and display array elements //info(strFmt("Element %1: ", intArray.value(1))); //info(strFmt("Element %1: ", intArray.value(2))); //info(strFmt("Element %1: ", intArray.value(3))); //info(strFmt("Element %1: ", intArray.value(4))); //info(strFmt("Element %1: ", intArray.value(5))); // Access and display array elements using a loop for (int i = 1; i <= intArray.lastIndex(); i++) { info(strFmt("Element %1: %2", i, intArray.value(i))); } } }