Created
August 25, 2019 08:54
-
-
Save rail-rate/21737d4200a2ed07e8552d2e380ec5a9 to your computer and use it in GitHub Desktop.
コンストラクタ6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main(args: Array<String>) { | |
val a = Test(20) | |
}//main | |
class Test(var name : String, var age : Int){ | |
init{ | |
println("イニシャライザブロック内です。") | |
println("${name}です。${age}歳です。") | |
}//init | |
constructor(age: Int) : this("名無し", age) //この行はセカンダリコンストラクタ | |
}//Test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment