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の変数で表示してみる |
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.name = "山田" //Testクラスの変数に値を入れる | |
a.age = 20 //上記同様 | |
a.hello() //hello関数を呼び出してみる | |
a.konnichiha() //konnichiha関数を呼び出してみる | |
a.nihao() //nihao関数を呼び出してみる | |
}//main |
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>) { | |
} | |
class Test{ | |
var name = "" | |
var age = 0 | |
fun hello(){ | |
println("${name}です。${age}です。よろしく!") | |
}//hello |
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>) { | |
} | |
class Test{ //ここから | |
// ↓ | |
} //ここまでがTestクラス |
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 text = "abcde" | |
sub1(text) | |
} | |
fun sub1(a : String){ | |
try{ | |
sub2(a) | |
}catch(e : NumberFormatException){ //sub2から投げられた例外をここでキャッチ | |
println("sub1で処理") //表示されている |
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 text = "abcde" | |
sub1(text) | |
} | |
fun sub1(a : String){ | |
sub2(a) | |
} | |
fun sub2(a : String){ |
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 text = "abcde" | |
try{ | |
val number = text.toInt() | |
println("number = ${number}") | |
}catch(e : NumberFormatException){ | |
println("${text}は数字に変換出来ません") | |
}catch(e : ArrayIndexOutOfBoundsException){ | |
println("文字を入力してください") | |
}catch(e : Exception){ |
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 text = "abcde" | |
try{ | |
val number = text.toInt() | |
println("number = ${number}") | |
}catch(e : NumberFormatException){ | |
println("${text}は数字に変換出来ません") | |
}catch(e : ArrayIndexOutOfBoundsException){ | |
println("文字を入力してください") | |
}catch(e : Exception){ |
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 text = "abcde" | |
try{ | |
val number = text.toInt() | |
println("number = ${number}") | |
}catch(e : NumberFormatException){ | |
println("${text}は数字に変換出来ません") | |
}catch(e : ArrayIndexOutOfBoundsException){ //ここで2つ目のcatch | |
println("文字を入力してください") | |
} |
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 text = "abcde" | |
try{ | |
val number = text.toInt() | |
println("number = ${number}") | |
}catch(e : NumberFormatException){ | |
println("${text}は数字に変換出来ません") | |
} | |
} |