Break, Continue and Labeled for loop in Kotlin

  • April 10, 2019
  • Posted by : Mountain Tech Valley
  • ( 0 )  Comment

Today, we are going to look at break,  continue and labeled for loop in kotlin. Here is an example of for loop in kotlin fun main() { for(i in 1..4){ println(i) } } It’s output 1 2 3 4 Let’s say, we want to exit our for loop when i=2, then, we need to use […]

Posted in Kotlin Leave a Comment on Break, Continue and Labeled for loop in Kotlin

Functions as a expression in Kotlin

  • April 10, 2019
  • Posted by : Mountain Tech Valley
  • ( 0 )  Comment

In this blog, we will look at how we can use function as a expression to return value from it. Here is a traditional function to get the maximum numbers between two numbers fun main() { println(“Max number is “+max(4,5)) } fun max(num1:Int, num2:Int):Int{ if(num1>=num2){ return num1 }else{ return num2 } } However, kotlin provides […]

Posted in Android, Kotlin Tagged , Leave a Comment on Functions as a expression in Kotlin

Getters and Setters with their visibility mode in Kotlin Programming language

  • March 31, 2019
  • Posted by : Mountain Tech Valley
  • ( 0 )  Comment

In this tutorial, we are going to see getters and setters in kotlin programming language. Here is basic class called Animal and it has two member variables name and message. Member variable message has getters and setters. It has a default getter implementation whereas setter has customer implementation. Field simply refers to the message variable. If you see field variable in getters and setters , then just remember that it is referring to its member variable. 

Posted in Android, Kotlin Tagged , Leave a Comment on Getters and Setters with their visibility mode in Kotlin Programming language