Kotlin
Beginner
1 min read
What Is Kotlin?
Example
// Hello World in Kotlin
fun main() {
println("Hello, Kotlin!")
}
// Top-level functions, no class wrapper needed
fun greet(name: String): String {
return "Hello, $name!"
}
// Single-expression function shorthand
fun square(x: Int) = x * x
// String templates with expressions
fun describe(n: Int): String {
return "The square of $n is ${square(n)}"
}
fun main2() {
val message = greet("World")
println(message)
println(describe(5))
// Type inference
val language = "Kotlin" // inferred as String
var version = 2.0 // inferred as Double
version += 0.1
println("$language $version")
}
Related Resources
Kotlin Reference
Complete tag & property list
Kotlin How-To Guides
Step-by-step practical guides
Kotlin Exercises
Practice what you've learned
More in Kotlin