Created
August 17, 2019 12:36
-
-
Save rail-rate/ef6b4ca96bee8b4700167240a3fbd2fd to your computer and use it in GitHub Desktop.
class4
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() //aと言う変数でインスタンスを生成 | |
a.name = "山田" //aの変数に値を入れる | |
a.age = 20 //上記同様 | |
a.hello() //aの変数で表示してみる | |
val b = Test() //bと言う変数でインスタンスを生成 | |
b.name = "鈴木" //bの変数に値を入れる | |
b.age = 15 //上記同様 | |
b.hello() //bの変数で表示してみる | |
val c = Test() //cと言う変数でインスタンスを生成 | |
c.name = "佐藤" //cの変数に値を入れる | |
c.age = 30 //上記同様 | |
c.hello() //cの変数で表示してみる | |
}//main | |
class Test{ | |
var name = "" | |
var age = 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