1. 程式人生 > >Kotlin 數據類型

Kotlin 數據類型

mil var family ont cells pre min blog str

Kotlin 的常見數據類型:

類型

範圍

byte

-128~127

short

32767
-32768

int

-2147483648~2147483647

long

9223372036854775807
-9223372036854775808

float

小數點6位

double

小數點後16

string

驗證代碼:

fun main(agrs : Array<String>)
{

var B:Byte= Byte.MAX_VALUE;
    println(
"max:"+B); B= Byte.MIN_VALUE println("min:"+B); var nub:Int=Int.MAX_VALUE; println("Max:"+nub) nub=Int.MIN_VALUE println("Min:"+nub) var nub_short:Short=Short.MAX_VALUE; println("Max:"+nub_short) nub_short=Short.MIN_VALUE println("Min:"+nub_short) var
nub_long:Long=Long.MAX_VALUE; println("Max:"+nub_long) nub_long=Long.MIN_VALUE println("Min:"+nub_long) var nub_double:Double=Double.MAX_VALUE println("Max:"+nub_double) nub_double=Double.MIN_VALUE; println("Min:"+nub_double) }

Kotlin 數據類型