How I can create Array of my custom objects with fixed size in Kotlin?
like?
ArrayList<CustomObject> array = new ArrayList<>()
or ?
CustomObject[] objects = new CustomObjects[5]
There are two options:
arrayOfNulls(size: Int) - creates an array of a specific size and populates it will null references. It's not possible to use this function with non-nullable types.<init>(size: Int, init: (Int) -> T) constructor - creates an array of a specific size and runs supplied lambda for every index in the array to create an element for that index.