Control Flow

Kotlin forEach Loop

Before we jump on for each that is our topic let’s first discuss the for each loop in java. For each loop in Java would like to be: class For_Each { public static void main(String[] arg) { { int[] marks = { 12, 32, 97, 126, 130 }; int highest_marks = maximum(marks); System.out.println(“The highest score …

Kotlin forEach Loop Read More »

Kotlin return Statement

We have often encountered scenarios where we want to use a function to return a value, like say a function to return a Boolean if passed String contains special characters, this is what exactly we will try to understand in this tutorial. Kotlin is a simple way of doing it by using return statement.

Kotlin for Loop

Before we jump on see what Kotlin has to offer in terms of for loop, let’s first recap the one we have used in Java. A typical Java for loop would like below: for (int i = 0;i<10;i++){ System.out.println(“Number is ” + i); }

Kotlin when Expression

If you are familiar with Java, then no course in Java is possible without flow of controls in which the switch forms a very important lesson. A typical switch looks like below: switch(weekNumber){ case 1:System.out.println(” MONDAY “); break; case 2:System.out.println(” TUESDAY “); break; case 3:System.out.println(” WEDNESDAY “); break; case 4:System.out.println(” THRUSDAY “); break; case 5:System.out.println(” …

Kotlin when Expression Read More »