在Scala中调用超类的构造函数

Scala超类构造函数 (Scala Superclass constructors)

A Constructor a method of the class that is used to initialize the object state in Scala class and are invoked by the compiler when the object of the class is created. In Scala programming language you can create any number of constructors for a class but there needs to be a single primary constructor which is the end of the constructor chain.

构造函数,该类的方法用于初始化Scala类中的对象状态,并在创建类的对象时由编译器调用。 在Scala编程语言中,您可以为一个类创建任意数量的构造函数,但必须有一个主构造函数,该主构造函数位于构造函数链的末尾。

If we define a subclass, then it has to by default call any of the constructors of the superclass in its object creation. The calling constructor of the superclass can be a call to any of the available constructor of the superclass (primary or auxiliary).

如果我们定义一个子类,则默认情况下它必须在其对象创建中调用超类的任何构造函数超类调用构造函数可以是对超类任何可用的构造函数(主或辅助)的调用。

There are multiple ways for calling a constructor of superclass,

有多种方法可以调用超类的构造函数,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值