從大數據菜鳥走上大師的歷程 Scala 第十一講 extends

子類繼承父類 要完成父類參數的填充
class Person(val name : String ,val age : Int)
{
println("father's constructor")
  val Class = "first class "
  def read = "10 hours"
  override def toString = "I am a good person"
}

class Stu(nameStu : String,ageStu : Int,val sex : String) extends Person(nameStu,ageStu)
{
  println("son's constructor")
  override val Class = "I'm a student in first class"
  override def toString = "I am a good student "
}

object Uni {
  def main(args: Array[String]): Unit = {
      
    val stu = new Stu("stu1",20,"男")
    println(stu.Class)
    println(stu.toString())
    
  }  
}
運行結果
father's constructor
son's constructor
I'm a student in first class
I am a good student

如今正是學習大數據的最好機遇,不花一分錢就能夠成爲大數據高手,實現年薪50萬的夢想。html

王家林的第一個中國夢:免費爲全社會培養100萬名優秀的大數據從業人員!微信

若是您有興趣請點擊這個連接進入大數據的學習ide

http://blog.sina.com.cn/s/blog_8fbd39ee0102vto3.html學習

若是您確實感受視頻教程有幫助,您能夠經過王家林老師的微信號18610086859發紅包捐助大數據、互聯網+、O2O、工業4.0、微營銷、移動互聯網等系列免費實戰課程大數據

您也能夠經過如下二維碼關注 DT大數據夢工廠視頻

相關文章
相關標籤/搜索