就是类中定义类
package loaderman.demo class Outer { var name: String = "name" inner class inner {//inner关键字获取外部类的实例引用 fun getName(): String = name } class Ha{ fun go()=3 } }
package loaderman import loaderman.demo.Outer fun main(arg: Array<String>) { val name = Outer().inner().getName()//注意 Outer()和Outer区别 val go = Outer.Ha().go() println(name) println(go) }
原文地址:https://www.cnblogs.com/loaderman/p/10126153.html
时间: 2024-10-11 03:28:59