kotlin

kotlin

Kotlin 'also' scope function examples

Kotlin provides one scope function called also that can be used to perform some actions on an object. You can read it like also do this for it. It returns the same object and the context object is available as it. You can use it instead of the whole object.

Read
kotlin

Kotlin program to get the current time in milliseconds

Learn how to get the current time in milliseconds in Kotlin. We will learn how to do it using currentTimeMillis and by using the calendar class with examples.

Read
kotlin

How to use Scanner class in Kotlin to read user inputs

Scanner class is actually a Java class. It is defined in java.util package. If you are from Java background, you must be aware of this class and how to use it. In Kotlin also, we can create one Scanner variable and use it to read user inputs.

Read
kotlin

Kotlin program to print the Fibonacci series

In this tutorial, we will learn how to print the Fibonacci series in Kotlin. The Fibonacci series is a series of numbers where each value is the sum of its two preceding values. For example, 0,1,1,2,3,5,8,13 is the Fibonacci series of size 8. We will write programs to print the Fibonacci series of different length i.e. it will take the size and print out the series of that size.

Read
kotlin

Kotlin program to get the substring after a special character

Our problem is to get the substring after the last occurrence of a special character in a string in Kotlin. For example, if our string is https://www.codevscolor.com, and if we need the substring after the last occurrence of '/', it should return www.codevscolor.com.

Read
kotlin

Kotlin for loop explanation with examples

for loop in Kotlin is used to iterate through an iterator. You can iterate through array, map or anything that provides an iterator. In this tutorial, I will show you how to use a for loop in Kotlin with different examples. It's syntax is :.

Read
kotlin

Check odd or even using 'when' in Kotlin

We can always find if a number is odd or even is to use one if-else block. This is the easiest process used in all programming languages. But in Kotlin, we can also use one when block. when block is more powerful. You can use it as a statement or as an expression. statement means it will work as an if-else statement and expression mean it will return value based on an input.

Read
kotlin

How to find all vowels in a string in Kotlin

This tutorial will show you how you to find all vowels in a string. We can iterate through the characters of a string one by one and verify if it is a vowel or not one by one. Iterating through the characters of a string can be done in multiple ways. I will show you three different ways to solve this problem.

Read
kotlin

How to use plus and minus operators in Kotlin

In kotlin, we can use the + and - operators to add or subtract multiple collections. The first operand is a collection and the second operand is a collection or an element. It returns one new collection.

Read
kotlin

Boolean functions in Kotlin

Boolean is used to represent a value that is either true or false. Booleans are useful for decision-making statements. Kotlin provides many methods for logical operations, finding the string representation, equality check, hashcode, etc. In this tutorial, we will check these functions with examples :.

Read