1、scala trait(特征)和abstract class(抽象类)的区别?

  scala中一个类可以继承多个特征中间用with相连;

  trailt中的定义的方法,可以有实现,也可以没有实现;

 

  抽象类不能多继承,只能是单继承;

  抽象类和java的抽象类类似,可以有抽象方法,也可以有非抽象方法;

  抽象类有带参数的构造函数,特质不行(如 trait t(i:Int){} ,这种声明是错误的)

 

scala trait :https://blog.csdn.net/qq_45538338/article/details/105203075?%3E

  

 

相关文章:

  • 2022-12-23
  • 2021-10-10
  • 2021-08-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-01
  • 2021-06-08
  • 2021-10-03
  • 2022-12-23
  • 2019-12-30
相关资源
相似解决方案