Skip to content

Instantly share code, notes, and snippets.

@rail-rate
Created August 17, 2019 12:36
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/ef6b4ca96bee8b4700167240a3fbd2fd to your computer and use it in GitHub Desktop.
Save rail-rate/ef6b4ca96bee8b4700167240a3fbd2fd to your computer and use it in GitHub Desktop.
class4
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