Concept Flow - Explicit type declaration
Start
Declare variable with type
Assign value matching type
Use variable
End
This flow shows declaring a variable with a specific type, assigning a matching value, then using it.
var name: String name = "Alice" var age: Int age = 30 println("Name: $name, Age: $age")
| Step | Action | Variable | Type | Value | Output |
|---|---|---|---|---|---|
| 1 | Declare 'name' with type String | name | String | uninitialized | |
| 2 | Assign "Alice" to 'name' | name | String | "Alice" | |
| 3 | Declare 'age' with type Int | age | Int | uninitialized | |
| 4 | Assign 30 to 'age' | age | Int | 30 | |
| 5 | Print values | Name: Alice, Age: 30 |
| Variable | Start | After Step 2 | After Step 4 | Final |
|---|---|---|---|---|
| name | uninitialized | "Alice" | "Alice" | "Alice" |
| age | uninitialized | uninitialized | 30 | 30 |
Explicit type declaration in Kotlin: val variableName: Type = value var variableName: Type = value - Declares variable with fixed type - Helps catch type errors early - Value must match declared type