Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Variables/Kotlin/variables.kotlin
Normal file
26
Task/Variables/Kotlin/variables.kotlin
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// version 1.0.6
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
/* read-only variables */
|
||||
val i = 3 // type inferred to be Int
|
||||
val d = 2.4 // type inferred to be double
|
||||
val sh: Short = 2 // type specified as Short
|
||||
val ch = 'A' // type inferred to be Char
|
||||
val bt: Byte = 1 // type specified as Byte
|
||||
|
||||
/* mutable variables */
|
||||
var s = "Hey" // type inferred to be String
|
||||
var l = 4L // type inferred to be Long
|
||||
var b: Boolean // type specified as Boolean, not initialized immediately
|
||||
var f = 4.4f // type inferred to be Float
|
||||
|
||||
b = true // now initialized
|
||||
println("$i, $d, $sh, $ch, $bt, $s, $l, $b, $f")
|
||||
|
||||
s = "Bye" // OK as mutable
|
||||
l = 5L // OK as mutable
|
||||
b = false // OK as mutable
|
||||
f = 5.6f // OK as mutable
|
||||
|
||||
println("$i, $d, $sh, $ch, $bt, $s, $l, $b, $f")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue