Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun main(args: Array<String>){
- var student = Student("Khoi")
- student.Name
- println( "value"+student.id)
- }
- //first constructor with properties
- class Student(var Name:String){
- //properties for secondary constructor
- var id:Int = -1
- init{
- println("Student name is $Name")
- }
- //secondary constructor
- //this - refer to 1st constructor
- constructor(name:String,id:Int):this(name){
- this.id=id
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement