List in Kotlin

Kotlin List

A list is a generic collection of elements. Kotlin has three Collections while List is one of those. The other two collections are Set and Map.

How Kotlin while Loop Works?

Kotlin while loop

In Kotlin, the while works just like in Java. So, if your background is Java then you already know how it works. For beginners, the while loops execute a block of code until the given condition is True.

How Kotlin “if” works?

Kotlin if expression

Kotlin if is an expression that returns a value. This is different if compared with the other languages where if acts as a statement. As, it acts as an expression in Kotlin, so there is no ternary operators (condition ? then : else).

Kotlin for Loop

Kotlin for loop

The for loop in Kotlin can be used to iterate through anything that provides an iterator. For example, a range, array, string, etc.