网站介绍:文章浏览阅读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”的伴生类与伴生对象;
- 链接地址:https://blog.csdn.net/qq_40333693/article/details/109243221
- 链接标题:初学伴生类和伴生对象_创建一个名字叫“test”的伴生类与伴生对象;-CSDN博客
- 所属网站:blog.csdn.net
- 被收藏次数:5084
- 网站标签:创建一个名字叫“test”的伴生类与伴生对象;