Created
August 26, 2019 13:03
-
-
Save rail-rate/2bd212f9d7bc5f44c7892095035b2509 to your computer and use it in GitHub Desktop.
コンストラクタ7
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){ | |
println("ここはセカンダリコンストラクタ内です。") | |
} | |
}//Test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment