Skip to main content
Advertisement

Kotlin (Android Development)

Kotlin is a modern, safe programming language selected by Google as the official language for Android development.

1. Features of Kotlin

  • Conciseness: It has significantly less boilerplate code compared to Java.
  • Null Safety: It provides language-level features to prevent NullPointerException.
  • Java Compatibility: It can be perfectly mixed and used with existing Java code.

2. Basic Syntax Taste

fun main() {
val name = "Kotlin" // Immutable variable (Read-only)
var age = 5 // Mutable variable

println("Hello, $name!")
}

3. Core Android Components

  1. Activity: A component responsible for one page of the screen.
  2. Fragment: A piece that makes up a part of the UI within an Activity.
  3. Intent: Used to pass data between components or request functions.
  4. Jetpack Compose: The latest declarative UI framework recommended by Google.

4. Jetpack Compose Example

@Composable
fun Greeting(name: String) {
Text(text = "Hello $name!", color = Color.Blue)
}

In the next section, we'll learn about Swift, which supports Apple's mobile ecosystem.

Advertisement