In this Kotlin programming tutorial, we will learn how to check if a number is positive, negative or zero in Kotlin. We will implement this program with a when block.
ReadConvert a string to a date in Kotlin with example. We will use java.util.LocalDate class to convert a string to a Date.
ReadIn this tutorial, we will learn how to take user input in Kotlin with different examples. Reading user input in Kotlin is easy. Kotlin provides one inbuilt function to make this task easy for us.readLine() function allow us to read the input that is entered by the user. This function actually read the input as a string. We can convert it to a different datatype if we want.Alternatively, we can also use Scanner class to read the content of user input.
ReadSafe call operator is denoted by ? in Kotlin. This operator is mainly used to remove null pointer exception or NPE in Kotlin. In this tutorial, we will learn how to use safe call operator in Kotlin with different use cases.In this tutorial, we will learn how to use safe call operator in Kotlin with different use cases.
ReadNamed argument is used to improve the readability of a kotlin function. Named argument, as the name suggested is arguments with a name. For example, let's take a look at the below function :.
ReadElvis operator is used to removing null pointer exception in Kotlin. We can use it to check if any variable is null or not and it allows us to use one default value if the value is null.The syntax of elvis operator is ?.
ReadDouble bang (!!) or double exclamation operator or not-null assertion operator is used with variables if you are sure that the value will be always non-null.If a value is null and if we are using not-null assertion operator, it will throw one null pointer exception.So, we should use this operator only if we want to throw one exception always if any null value found.
ReadThis post is about "default arguments" in kotlin and their use cases.
ReadThe intersection is used to find out the common elements in two arrays. For example, if array A holds 1,2,3,4,5 and array B holds 2,5,6, the intersection between A and B will be 2,5.In this tutorial, we will learn how to find out the intersection between two array elements.
ReadLearn to sort a list of items in Kotlin in both ascending and descending orders. We will also learn how to sort a list of objects with a comparator and with a selector.
Read