【问题标题】:Creating array of objects with fixed size in Kotlin在 Kotlin 中创建具有固定大小的对象数组
【发布时间】:2020-06-19 19:09:40
【问题描述】:

如何在 Kotlin 中创建具有固定大小的自定义对象数组?

喜欢吗?

ArrayList<CustomObject> array = new ArrayList<>()

还是?

CustomObject[] objects = new CustomObjects[5]

【问题讨论】:

    标签: android arrays kotlin


    【解决方案1】:

    有两种选择:

    【讨论】:

    • private val customObjectArray = arrayOfNulls(5) customObjectArray[0] = CustomObject(this, 2)
    猜你喜欢
    • 1970-01-01
    • 2020-04-26
    • 1970-01-01
    • 2015-05-05
    • 1970-01-01
    • 2019-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多