
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

5K+ Views
In Kotlin, we have three types of structural jump expressions: "break", "return", and "continue". In this article, we will see how break and continue work in Kotliln.Break - This is a keyword that helps in terminating an iteration, once a given condition is met, while traversing through a collection.Continue - This keyword helps to continue the iteration once a condition is fulfilled.In Kotlin, we cannot explicitly use break and continue statements explicitly inside a forEach loop, but we can simulate the same action. In this example, we will see how to do it.Example: Return at labels :: directly to the ... Read More

2K+ Views
Swift "if let" is a conditional check operator to check whether a reference variable is NULL or not. This is a very useful technique to evaluate the unwrap optional value using swift language.In Kotlin, we can't use this operator directly. Instead, we will be using "let" and "run" to evaluate the same. In the following example, we will see how to use "let" and "run" using Kotlin library class.Example: Null Check using 'let' and 'run'In this example, we will check whether the value of a reference variable is NULL or not. If the value of the reference variable is NULL, ... Read More

866 Views
In object-oriented programming, the creation of objects is very easy via constructors when the object definitions are simple, but sometimes, it may so happen that the constructors need more variables or functions in order to initialize an object. In such cases, the "builder pattern" comes into picture which helps programmers to create small units of different objects and create a final object.A builder pattern provides an API to construct an object step- by-step.Builder patterns are particularly useful when objects need to be created dynamically.Note that it is not recommended to use builder patterns in Kotlin because we can get the ... Read More

808 Views
Kotlin is a statistically typed language that runs on JVM. Once a Kotlin file is compiled, it creates a .class file that can be executed on the JVM. In this article, we will see how we can convert a Kotlin source file to a Java source file. In this process, we will be taking help from different online Decompilers available on the Internet.Open VS Code.Go to the "extension" section and install "Kotlin language support for VS Code" and "Code Runner". We need these two extensions to run Kotlin in VS code environment.Install Kotlin compiler in your system as per the ... Read More

2K+ Views
In this article, we will see how to convert a String to Long in Kotlin using a library function. There are multiple ways to do it. Let's take a couple of examples to demonstrate how it's done.Example - using toLong()toLong() is a function that provides the most convenient way to convert a string to a long. In the following example, we will see how we can use toLong() to convert our String.fun convertToLong(s: String) { try { val value = s.toLong() println("The Long value is: $value") } catch (ex: ... Read More

294 Views
Varargs, also known as "variable arguments" is a new mechanism in Java by which methods in Java can accept zero or multiple number of arguments. Before this mechanism, the only option available to achieve this type of functionality was "method overloading", but that also required multiple lines of boilerplate code.In this article, we will see how we can use Varags in Kotlin to call a function multiple times based on different types of arguments. The following example demonstrates how we can use this Varags keyword.Examplefun main() { // calling the function with 4 arguments and // passing 3 ... Read More

2K+ Views
In Kotlin, you can easily call another function by just importing the same in the current Kotlin file where your main function is running. Whatever the function we are declaring in a Kotlin file will be compiled into a static method by default, and it will be placed under the same package. The name of the newly created file will be renamed as the First letter capitalized and ".kt" extension replaced with the "Kt" suffix.In this article, we will try to get an insight into how you can use Kotlin extension methods from a Java file.ExampleLet's create a Kotlin file ... Read More

5K+ Views
In this article, we will see how we can convert a List to a Map using various options provided by the Kotlin Library.Example: Using associate()The most standard way of converting a list into a map is by using the associate() function. This function takes a list of items as an argument and it returns a map containing key-value pairs. In the following example, we will see how it works.Exampledata class mySubjectList(var name: String, var priority: String) fun main() { val mySubjectList: List = listOf( mySubjectList("Java", "1"), mySubjectList("Kotlin", "2"), mySubjectList("C", ... Read More

3K+ Views
Kotlin is based on Java, hence we can use Java-based library functions to delay a function call. In this article, we will be using a Java library function to delay the function call using Timer() and schedule().Exampleimport java.util.Timer import kotlin.concurrent.schedule fun main(args: Array) { // Execution starting point println("Hello world!!") // Delay of 5 sec Timer().schedule(5000){ //calling a function newMethod() } } fun newMethod(){ println("Delayed method call!") }OutputOnce executed, the above piece of code will yield the following output −Hello world!! Delayed method call!

315 Views
String is a collection which is implemented using String class. As per the Kotlin documentation, a string can be defined as follows −Class String : Comparable, CharSequenceIn Kotlin, a string is a collection of characters. Strings are immutable in nature which means they are read-only. The length and elements of a string can be modified once declared.In Java, we have an option to create an empty String array by defining it like String[]. In this article, we will see how we can achieve the same using Kotlin library function.Example: Using arrayOf()Kotlin library provides a function to create an array of ... Read More