Kotlin Basics
1. Introduction
- Kotlin is a modern, concise, safe, and interoperable language developed by JetBrains.
- Fully compatible with Java.
2. Hello World
```kotlin
fun main() {
println("Hello, World!")
}
```
3. Variables
```kotlin
val name = "Rakesh" // immutable
var age = 25 // mutable
```
4. Data Types
- Int, Long, Double, Float, Char, String, Boolean
```kotlin
val x: Int = 10
val pi: Double = 3.14
val isKotlinFun: Boolean = true
```
5. Conditional Statements
```kotlin
val number = 10
if (number > 0) {
println("Positive")
} else {
println("Non-positive")
}
```
6. Loops
```kotlin
for (i in 1..5) {
println(i)
}
var i = 1
while (i <= 5) {
println(i)
i++
}
```