
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1952 Articles for Apps/Applications

2K+ Views
In this article, we will take a couple of examples to demonstrate how we can split a given String in Kotlin using some given delimiters.Example – Split a String using given delimitersIn this example, we will create a String and we will store some value in it and we will try to split the same using some delimiters.fun main(args: Array) { var str = "Tut@or@ia@lsPo@int.@com" var delimiter = "@" // It will split the given String using '@' val parts = str.split(delimiter) print(parts) }OutputIt will generate the following output −[Tut, or, ... Read More

849 Views
Switch-case statement in any programming language allows the programmers to testify it against different values. It also provides an option to do something whenever the value of the variable does not match with a given value. In this article, we will take a simple example and demonstrate how we can implement the switch-case statement in Kotlin.Kotlin does not provide any option to write a switch-case statement. However, Kotlin provides an option to implement when() which works exactly the same way switch works in other programming languages.Example – Implementing switch-case in JavaIn this example, we will implement switch-case in Java.public class ... Read More

5K+ Views
In this article, we will see three different ways to check whether a String is empty in Kotlin.Example – isEmpty()Kotlin library function isEmpty() can be used in order to check whether a String is empty. Note that it counts spaces too.fun main(args: Array) { // No space between the quotes val myString = "" // Space between the quotes val anotherString = " " println(myString.isEmpty()) // this will return false as we have a space println(anotherString.isEmpty()) }OutputOn execution, it will produce the following output −true falseObserve that the second ... Read More

546 Views
Kotlin provides four types of constructors to define and manipulate a HashMap. In this article, we will see how we can reverse a map using Kotlin library function.A Map is a collection where data is stored as a key-value pair and the corresponding key has to be unique.A HashMap is a collection class based on MutableMap interface and it does that by implementing the MutableMap interface of HashTable.Example − Reverse using Iterable associate()In this example, we will create a HashMmap and we will reverse the same using associate(). In this method, we will be creating a new map and we ... Read More

6K+ Views
Kotlin is a statistically typed language and it is based on Java, hence all the Java code can easily be compiled within Kotlin code. In this article, we will see how we can generate the current local date and time in Kotlin.As Kotlin is interoperable with Java, we will be using Java utility class and Simple Date Format class in order to convert TimeStamp into DateTime.Example – Converting DateTime using Java util classAs Kotlin is comparable with the JVM, we can use the Java util class in order to convert the TimeStamp into DateTime.import java.text.SimpleDateFormat import java.util.* fun main(args: ... Read More

194 Views
In this example, we will see how to print 0001 to 1000 in Kotlin with padding. For this purpose, we will use a Kotlin library function called padStart().padStart is a function which returns a charSequence. Its function definition looks like this −fun CharSequence.padStart( length: Int, padChar: Char = ' ' ): CharSequenceExample – Print 0001 to 1000 with paddingThe following code prints 1 to 1000 with padding.fun main(args: Array) { (1..1000).forEach{println("$it".padStart(4, '0'))} }OutputOn execution, it will print a sequence of 4-digit numbers starting from 0001 to 1000.0001 0002 0003 0004 ... ... ... 0996 0997 0998 0999 1000

662 Views
In this article, we will take an example and show how to print all the elements of a String array in a single line using a Kotlin library class. In order to do that, we will use a String function called joinToString(), provided by the Kotlin library.As per the Kotlin documentation, the function definition looks like this −fun Array.joinToString( // the String will be separated by this separator: CharSequence = ", ", // This will be added as prefix to the String prefix: CharSequence = "", // This will be added as postfix ... Read More

2K+ Views
Kotlin is statistically typed language and it is hundred percent comparable with Java, as it was developed based on JVM. In Kotlin, there are two types of equality checks −One is denoted by "==" andThe other one is denoted by "===".As per the official documentation, "==" is used for structural equality, whereas "===" is used for referential equality.For any expression, a==b will evaluate to True only when the value of both "a" and "b" are equal.a===b will evaluate to True only when both "a" and "b" are pointing to the same object.Example – Equality in KotlinIn this example, we will ... Read More

2K+ Views
In this article we will see how we can remove an item from an ArrayList using Kotlin library function. In order to do that, we will take the help of a library function called drop(). The function definition looks as follows −fun Array.drop(n: Int): List (source)It takes array and a position as an input and it returns a list containing all the elements except the first n elements.Example – drop() in KotlinIn this example, we will remove the first element from a list using drop().fun main(args: Array) { var arrayone: ArrayList = arrayListOf("mango", "jam", "apple", "lemon", "spice") ... Read More

1K+ Views
A list is a collection to hold same type of data in a single variable. Kotlin does not provide any dedicated literal to create a collection. As per the documentation of Kotlin, a List is an ordered collection with access to elements by indices.In Kotlin, we do have two different kinds of collections; one is read-only which is known as immutable collection and the other type of collection is where we can have a write facility as well which is known as mutable collection.In this article, we will see how we can create these two types of lists and manipulate ... Read More