Kotlin的静态常量写法

Kotlin的静态常量写法有两种
1 放到class外
2 companion object

//1 放到class外
private const val UNSPLASH_STARTING_PAGE_INDEX = 1
class MyObject{
	...
}

//2 companion object
class MyObject{
    ...
    companion object {
            private const val NETWORK_PAGE_SIZE = 25
    }
}

你可能感兴趣的:(随笔,android,java)