gpt4 book ai didi

scala - 在Scala中,Any和Object有什么区别?

转载 作者:行者123 更新时间:2023-12-01 23:16:33 27 4
gpt4 key购买 nike

假设我有以下java方法

protected void onEvent(Object obj) {

}

Scala 编译器接受

protected override def onEvent(event: Any)

protected override def onEvent(event: Object)

两者有什么区别吗?

最佳答案

有一个article在 scala-lang 上,有很棒的图表(我什至把它卡在墙上)。还需要提及的是:

If Scala is used in the context of a Java runtime environment, then scala.AnyRef corresponds to java.lang.Object.

关于scala - 在Scala中,Any和Object有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7160984/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com