利用主构造器传递参数 class Counter(val name:String, val mode:Int){ private var value = 0 def increment(step:Int):Unit={value += step} def current():Int={value} def info():Unit={printf(Nama:%s, mode:%d,name, mode)} } object myCounter{ def main(args:Array[String]){ val my_counter