就是类中定义类
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) }