kotlin
val numbers = listOf(1, 2, 3, 4, 5)
val evenNumbers = numbers.filter { it % 2 == 0 }
val doubledNumbers = numbers.map { it * 2 }
val sum = numbers.reduce { sum, element -> sum + element }
kotlin
fun interface Calculator {
fun calculate(x: Int, y: Int): Int
}
val add: Calculator = Calculator { x, y -> x + y }
val multiply: Calculator = Calculator { x, y -> x * y }
kotlin
import java.util.Optional
val name: Optional<String> = Optional.ofNullable("John")
name.ifPresent { value -> println(value) }
val defaultValue = name.orElse("Unknown")
kotlin
import java.time.LocalDateTime
val now = LocalDateTime.now()
val formattedDateTime = now.format(DateTimeFormatter.ISO_DATE_TIME)
val isAfter = now.isAfter(timestamp)
val duration = Duration.between(startTime, endTime)
kotlin
import kotlin.streams.toList
val numbers = listOf(1, 2, 3, 4, 5)
val parallelStream = numbers.parallelStream()
val evenNumbers = parallelStream.filter { it % 2 == 0 }.map { it * 2 }
val result = evenNumbers.toList()