What is SAM Conv...
What is SAM Conv...
SAM Conversion in Kotlin refers to the ability to use lambda expressions to implement interfaces with a single abstract method (SAM). This feature allows for more concise and readable code when working with functional interfaces[1][3].
Here's how it works:
fun
modifier before the interface keyword[3].For example, consider this Kotlin functional interface[3]:
fun interface Runnable {
fun run()
}
Without SAM conversion, you would need to write[3]:
val runnable = object : Runnable {
override fun run() {
println("Running...")
}
}
With SAM conversion, you can simply use a l...
expert
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào