初学伴生类和伴生对象_创建一个名字叫“test”的伴生类与伴生对象;-CSDN博客

网站介绍:文章浏览阅读229次。伴生类和伴生对象应在同一个文件中,名字相同;class类称为object的伴生类,object称为class的伴生对象实例1:class Person(uname: String,Uage: Int) { println("class 进入到Person的class类中") var name: String = uname var age: Int = age private var address: String = "亚洲" def this() { //从构造方法 this("xx_创建一个名字叫“test”的伴生类与伴生对象;