

Hence, different type of elements can be added to this array: val differentTypeArray = arrayOf(10,4,5,"Array string", 'c', 10.5f)Īs you can see in the code example above, different types of elements are added to this array. In the above example, the type of array is not mentioned. The size of this array will be fixed i.e. As the size of array is fixed, we cannot add elements to this later on. In the code above, we created an array of integers.

Let us create an array of integers: val marks = arrayOf(10,9,3,4,5) We can pass the array elements as the parameter while calling the arrayOf() function. The easiest way to create an array is using arrayOf() function.

We will first see how to create array using functions and later we will see how we can create using the Array class. In Kotlin the array can be created using Array class and using some Kotlin functions.
