当前位置:网站首页>Scala trait inheritance class

Scala trait inheritance class

2022-06-25 01:03:00 Jue Niu thunder plough hot blade

/** * Scala in , Traits can also inherit classes , The trait will inherit all the members in the class  */
object  Trait inheritance class  {
    

  class Message {
    
    def printMsg(): Unit = println(" Learn from good examples Scala, I'm not afraid to go anywhere ")
  }

  trait Logger extends Message

  class ConsoleLogger extends Logger

  def main(args: Array[String]): Unit = {
    
    val cl = new ConsoleLogger
    cl.printMsg()
  }

}
原网站

版权声明
本文为[Jue Niu thunder plough hot blade]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202210544014014.html