Kotlin Programming with IntelliJ IDEA
Write concise, null-safe Kotlin in IntelliJ IDEA: functions and lambdas, data and sealed classes, collections, coroutines, tests, and code that works hand in hand with Java.
Intermediate · Software Development · about 11 hours · 4 modules · certificate on completion
Taught by Abderrahmàn Bensoussàn, Rodrigoò Silvà, AI Learning Companions.
About this course
Kotlin is a modern, concise language for the JVM, used for Android apps, back-end services and tools, and it works hand in hand with Java. This course is for people who can already program and want to write Kotlin well, in IntelliJ IDEA, the IDE from the company that created the language. Each lesson teaches a Kotlin idea and then shows it in the IDE, step by step, with the keyboard shortcuts for macOS, Windows and Linux. You'll set up Gradle projects and see how Kotlin's type system keeps null under control, write functions, extension functions and lambdas, and process data with Kotlin's collection operations. You'll model data with data classes, sealed hierarchies and objects, run work concurrently with coroutines, and test it all with kotlin.test. Finally you'll mix Kotlin with Java, calling each from the other and converting Java files to Kotlin in the IDE. Every module ends with a hands-on lab, and the course ends with a payment-processing project that you build yourself.
What you'll learn
- Set up Kotlin projects built with Gradle in IntelliJ IDEA, and run and test them from the IDE
- Write idiomatic Kotlin with val and var, type inference, null safety and when expressions
- Process data concisely with functions, extension functions, lambdas and collection operations
- Model data with classes, data classes, sealed classes and objects
- Run concurrent work with coroutines, test with kotlin.test, and mix Kotlin with Java, converting Java files in the IDE
Skills you'll gain
Kotlin, IntelliJ IDEA, Null safety, Functional programming, Coroutines, Gradle, Unit testing, Java interoperability
Tools
IntelliJ IDEA, Kotlin, Gradle
Before you start
Some programming experience in any language: variables, functions, loops and classes. Java experience helps in the last module but isn't required. IntelliJ IDEA (the free version is enough) on Windows, macOS or Linux; it supports Kotlin and Gradle out of the box and can download a JDK for you.
Modules
Kotlin, Gradle and null safety
Create a Kotlin project built with Gradle, meet Kotlin's types, val and var and its expressions, and see how the type system keeps null out of places where it doesn't belong.
- A Kotlin project with Gradle (11 min)
- val, var, types and expressions (12 min)
- Null safety (12 min)
- Hands-on lab: Parse a sensor log safely
Functions, lambdas and collections
Write functions the Kotlin way, with default and named arguments, expression bodies and extension functions; pass behaviour around with lambdas; and process data with Kotlin's collection operations.
- Functions and extension functions (12 min)
- Lambdas and higher-order functions (12 min)
- Working with collections (13 min)
- Hands-on lab: Build a text toolkit and a word report
Classes, data classes, sealed classes and objects
Model a domain the Kotlin way: classes with primary constructors and properties, data classes for values, sealed hierarchies that when can check completely, and objects for single instances.
- Classes, properties and constructors (12 min)
- Data classes and enum classes (11 min)
- Sealed classes and objects (12 min)
- Hands-on lab: Model payments with a sealed result
Coroutines, testing and Java interoperability
Run work concurrently with coroutines, test Kotlin code with kotlin.test, coroutines included, and mix Kotlin with Java: call each from the other, and convert Java files to Kotlin in the IDE.
- Coroutines: suspend functions, launch and async (14 min)
- Testing Kotlin with kotlin.test (12 min)
- Kotlin and Java together (13 min)
- Hands-on lab: Convert a Java class to idiomatic Kotlin
Project: Build a payment-processing pipeline
Build a command-line payment processor in Kotlin with IntelliJ IDEA and Gradle. It reads a CSV file of payments and checks each line, reporting bad lines instead of crashing. It then checks the payments concurrently against a simulated risk service written with suspend functions, with a timeout so that one slow check can't hold up the rest. Model payments as data classes and outcomes as a sealed hierarchy (approved, declined with a reason, sent for review, timed out), handle every outcome with exhaustive when expressions, and print a report with totals per country and per outcome, built with collection operations. Include one Java class that the Kotlin code calls, such as an existing currency formatter, and make one Kotlin API pleasant to call from Java with @JvmStatic or @JvmOverloads. Test it with kotlin.test, including a coroutine test with runTest.
Part of
IntelliJ IDEA is a trademark of JetBrains s.r.o. This course is independent: JetBrains hasn't made or endorsed it.