Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rail-rate
Created June 29, 2019 11:17
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/bcdb449228cdd3c511f0278b51e472c9 to your computer and use it in GitHub Desktop.
Save rail-rate/bcdb449228cdd3c511f0278b51e472c9 to your computer and use it in GitHub Desktop.
型変換2
fun main(args: Array<String>) {
val ten : Int = 100000
val a : Byte = ten.toByte() //Byte型に変換
val b : Short = ten.toShort() //Short型に変換
val c : Int = ten.toInt() //Int型に変換
val d : Long = ten.toLong() //Long型に変換
val e : Double = ten.toDouble() //Double型に変換
val f : Float = ten.toFloat() //Float型に変換
val g : String = ten.toString() //String型に変換
println("Byte = " + a)
println("Short = " + b)
println("Int = " + c)
println("Long = " + d)
println("Double = " + e)
println("Float = " + f)
println("String = " + g)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment