Kotlin Basic Syntax
Essential Kotlin syntax and program structure
Variables
val name = "John" # immutable variable
var age = 25 # mutable variable
val price: Double = 99.99 # explicit type
const val PI = 3.14 # compile-time constant
Data Types
Int # integer numbers
Long # long integers
Double # floating point
Float # 32-bit float
String # text values
Boolean # true or false
Char # single character
String Operations
val text = "Hello"
text.length # get length
text.uppercase() # convert to uppercase
text.lowercase() # convert to lowercase
"Name: $name" # string interpolation
"Sum: ${a + b}" # expression in string
Print Output
println("Hello World") # print with newline
print("Text") # print without newline
Comments
// single line comment
/* multi-line
comment */