// Initializing array and list val array = arrayOf(1, 2, 3) //pure array val list = listOf("apple", "ball", "cow") //pure list val mixedArray = arrayOf(true, 2.5, 1, 1.3f, 12000L, 'a') // mixed Array val mixedList = listOf(false, 3.5, 2, 1.4f, 13000L, 'b') // mixed List Arrays An array is a container object that holds a fixed number of values of a single type. The length of an array is established when the array is created. After creation, its length is fixed. Arrays can be concatenated to give a new Array val array1 = arrayOf(1, 2, 3, 4, 5, 6) val array2 = arrayOf(7, 8, 9, 10, 11, 12) val newArray = array1 + array2 for(element in newArray) { println("$element - ") } // 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 Lists A list is an interface. It is a generic ordered collection of elements. Methods in this interface support only read-only access to the list; read/write access is supported through the MutableL...
Comments
Post a Comment