我是Android应用程序开发和OOP的新手。在使用Kotlin开发应用程序时,我在java文件夹中创建了一个Kotlin类文件。
Kotlin类文件包含class Users (FirstName : String , LastName : String?, UserName : String, PassWord : String, Phone : Int, Age : Int , Weight : Int, Height : Int){}
下面的代码
我可以知道我在Kotlin类文件中创建的类是否是公共类吗?此外,我可以使用对象的构造函数之一来创建该类的对象吗?
kotlin中的类默认为公共类。
在kotlin中,可以有一个主构造函数或一些辅助构造函数。
主构造函数示例:
class Test(
private val a: Int,
private val b: Int) {}
二级建造师样本:
class Test {
// First secondary constructor
constructor(a: Int)
// Second secondary constructor
constructor(a: Int, b: Int) }