Skip to content

Instantly share code, notes, and snippets.

@rail-rate
Created August 20, 2019 14:04
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/c3bcc0e399231a63a044f9f27f93d51d to your computer and use it in GitHub Desktop.
Save rail-rate/c3bcc0e399231a63a044f9f27f93d51d to your computer and use it in GitHub Desktop.
コンストラクタ3
fun main(args: Array<String>) {
val a = Test(age = 20, name ="山田") //名前と年齢
val b = Test(name = "山田") //名前だけ
val c = Test(age = 20) //年齢だけ
a.hello()
b.hello()
c.hello()
}//main
class Test(var name : String = "", var age : Int = 0){
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