works:programmer:java:kotlin:hellow
Привет мир
// constants val one = 1 // Int val threeBillion = 3000000000 // Long val oneLong = 1L // Long val oneByte: Byte = 1 // variables var a: Byte = 0 // signed 1 byte var b: Short = 0 // signed 2 bytes var c: Int = 0 // signed 4 bytes var d: Long = 0 // signed 8 bytes var ff: Float = 0f // 32 bit floating var fd: Double = 0.0 // 64 bit floating /* * All number types support conversions to other types: toByte(): Byte toShort(): Short toInt(): Int toLong(): Long toFloat(): Float toDouble(): Double toChar(): Char */ val myTrue: Boolean = true val myFalse: Boolean = false val boolNull: Boolean? = null val str = "abcd 123" class Ref(val a: Int, val b: Int) { val customerKey = a.toString().uppercase() val area: String get() = a.toString() + "+" + b.toString() + "=" + (a + b).toString() private var customA: Int = 0; var refA: Int get() = customA set(value) { customA = if (value > 0) value else 0 } } fun demo(x: Any) { if (x is String) { print(x.length) // x is automatically cast to String } } fun main() { val asc = Array(5) { i -> (i * i).toString() } asc.forEach { println(it) } val name: String = "world"; val r = Ref(3, 17); println("Hello, ${name}!!!") println(r.area) }
works/programmer/java/kotlin/hellow.txt · Последнее изменение: 2022/02/24 05:37 — 127.0.0.1