Kotlin Switch Explained: Unlocking the Power of Kotlin when
The when in Kotlin defines a conditional expression with more than one branch, that’s the statement you need to use when you want to write a Kotlin switch. In Java, we are using switch case statements. In Java, we need to define a break in each switch case, but in Kotlin we don’t need to. There are two ways you can use them in Kotlin. Either as a statement or as an expression.