Skip to content

Instantly share code, notes, and snippets.

@rail-rate
Created August 21, 2019 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rail-rate/628d02a8201a952306ae770f43df2229 to your computer and use it in GitHub Desktop.
Save rail-rate/628d02a8201a952306ae770f43df2229 to your computer and use it in GitHub Desktop.
コンストラクタ5
fun main(args: Array<String>) {
val a = Test("山田", 20)
}//main
class Test(var name : String, var age : Int){
init{ //ここからイニシャライザブロック
println("イニシャライザブロック内です。")
hello()
}//init //ここまでイニシャライザブロック
fun hello(){
println("${name}です。${age}です。HELLO!")
}//hello
}//Test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment