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() { | |
println("Hello, world!") | |
} |
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() { | |
val userName = "Florian" | |
var age = 28 | |
println("Hello, world! My name is $userName. I am $age years old. In 2 years, I'll be ${age + 2}.") | |
} |
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() { | |
val exampleString = "\"Florian\nWalther\"" | |
val exampleRawString = """ "Florian | |
Walther" """ | |
print(exampleRawString) | |
val exampleNumber: Double | |
exampleNumber = 2_000_000.12 | |
val exampleLong: Long = exampleNumber.toLong() |
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() { | |
var a = 5 | |
val b = 3.0 | |
println("a = " + a + " b = " + b) | |
println("a + b = ${a + b}") | |
println("a - b = ${a - b}") | |
println("a * b = ${a * b}") | |
println("a / b = ${a / 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() { | |
var a = 5 | |
val b = 3.0 | |
println("a = " + a + " b = " + b) | |
println("a + b = ${a + b}") | |
println("a - b = ${a - b}") | |
println("a * b = ${a * b}") | |
println("a / b = ${a / 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() { | |
var a = 5 | |
val b = a.toLong() | |
println("a = " + a + " b = " + b) | |
// println("a + b = ${a + b}") | |
println("a - b = ${a - b}") // subtracts b from a | |
println("a * b = ${a * b}") | |
println("a / b = ${a / 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() { | |
val names = arrayOf("Jim", "John", "Jenny", "Jamie") | |
names[0] = "Jeremy" | |
println("Number of elements: ${names.size}") | |
println("First element: ${names[0]}") | |
println("Last element: ${names[2]}") | |
} |
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() { | |
val names = arrayOf("Jim", "John", "Jenny", "Jamie") | |
//for (name in names) println(name) | |
names.indices | |
//Index: ___ Element: ___ | |
//for (i in 1..10) println(i) |
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() { | |
println("2 > 1 is ${2 > 1}") | |
println("2 < 1 is ${2 < 1}") | |
println("1 >= 1 is ${1 >= 1}") | |
println("1 == 1 is ${1 == 1}") | |
println("1 == 2 is ${1 == 2}") | |
println("1 != 2 is ${1 != 2}") | |
println("!(2 > 1) is ${!(2 > 1)}") |
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() { | |
var i = 0 | |
outer@ do { | |
println(i) | |
i++ | |
//continue | |
var j = 0 |
OlderNewer