What Are Delegated Properties in Kotlin?

Delegated Properties are regular properties who delegate how they are either written or read (think getters or setters) to some other function. For example, let’s say we have the following class. class Dog { var isAGoodDoggo: Boolean = true } Now we all know that ALL dogs are good dogs, so let’s say we want isAGoodDoggo to […]

Read More

Kotlin Coroutines and Why They Are Necessary

Kotlin coroutines are very useful. In this article we will go through basic examples of using coroutines, and we will also examine what happens under the hood. Why are solutions like Coroutines necessary? Handling execution on multiple threads is unavoidable in modern application development. Drawing fancy loaders on the UI while waiting for a network […]

Read More

How do I run a Kotlin class on command line?

I can’t run a compiled Kotlin class. When I try to run it like I would a normal Java class I get the following: C:\Users\User\Desktop>java _DefaultPackage Exception in thread “main” java.lang.NoClassDefFoundError: jet/runtime/Intrinsics at _DefaultPackage.main(Finder.kt) Caused by: java.lang.ClassNotFoundException: jet.runtime.Intrinsics at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) … 1 […]

Read More

Things to Know about Kotlin Extension Functions

How many times have you wished there was a simpler way to add just a small piece of functionality to a class in Java? Whenever that happened, you might have ended up either extending the class or utility static method. Both works fine, but it feels like there should be something more convenient, right? If […]

Read More

Organizing Code with Packages in Kotlin

In this tutorial, you’ll learn how to organize your code using packages in Kotlin. Packages In Java we use packages to group related classes; for example, the java.util package has a number of useful utility classes. Packages are declared with the package keyword, and any Kotlin file with a package declaration at the beginning can contain declarations of classes, functions, or […]

Read More

Kotlin Singletons and Object Declarations

A singleton is a class which only allows one instance of itself to be created. This instance needs to also be globally accessible. Singletons are useful when exactly one object is needed to coordinate actions across the system. Object Declarations Kotlin provides an easy way to create singletons using the object declaration feature. For that, object keyword […]

Read More

How to Write Concise Code with Kotlin

One of the major selling points of Kotlin is its concise and expressive syntax. But in how far does Kotlin actually allow you to write more concise code? Let’s look at four ways it accomplishes this. Data Classes In Java, you sometimes create classes which act simply as data containers without much additional functionality. This may […]

Read More

Data Types in Kotlin

A variable is a location in memory that holds data. This tutorial will help you learn about variables in Kotlin, how they are created, and the basic data types that Kotlin supports for creating these variables. Declaring a variable in Kotlin To declare a variable in Kotlin, either var or val keyword can be used. Here is an example: […]

Read More

Hello World in Kotlin vs Java

The customary “Hello, World!” is a simple program that outputs Hello, World! on the screen. It is a very simple program and is often used to introduce a new programming language. Kotlin “Hello, World!” Program // Outputs Hello World fun main(args : Array<String>) { println(“Hello, World!”) } When you run the program, the output will be: Hello, […]

Read More

What is Kotlin?

What is Kotlin? Kotlin is a statically typed programming language that runs on the JVM (or Java Virtual Machine). It can be operated on multiple platforms and is compatible with Java, Android, JavaScript, as well as native applications. The language is developed by the team at JetBrains. JetBrains is committed to the project, has a […]

Read More