我有一个scala文件跟在类之后(以及主流方法):
class OuterClass {
class Inner {
def innerMethod(): Unit = {
println("innerMethod")
}
class InnerMost {
innerMethod()
}
}
}
现在想从main方法调用该类:
object main {
def main (args: Array[String] ): Unit = {
println("Main")
val pt = new OuterClass
...
}
}
如何实现?
答案 0 :(得分:3)
要实例化嵌套类Inner
,然后InnerMost
val pti = new pt.Inner
val ptim = new pti.InnerMost