class Student{var name:String=""var age =0// this 调用类成员 name 与 age,并赋值def info(name:String, age:Int){this.name = name
this.age = age
}def show(){
println(name +" is "+ age +" years old")}}var stu =new Student()
stu.info("Kabir",36)
stu.show()// Kabir is 36 years old
class Student{var name:String=""var age =0// this 创建辅助构造函数defthis(name:String, age:Int){this()// 第一行调用主构造函数this.name = name
this.age = age
}def show(){
println(name +" is "+ age +" years old")}}var stu =new Student("Kabir",36)
stu.show()// Kabir is 36 years old