SCALA中的抽象类代码样例

package com.hengheng.scala

class AbstractClass {

}
abstract class People {
  def speak

  val name : String
  var age : Int
}
class Worker extends People {
  def speak {
    println("Hello, Worker!!!")
  }
  val name = "Rocky"
  var age = 27
}
object AbstractClass extends App {
  val worker = new Worker
  worker.speak
  println(worker.name + ":" + worker.age)
}

  输出:

Hello, Worker!!!
Rocky:27

上一篇:Swift 脚本(运行时带参数)


下一篇:jQuery遍历