Menu
CoddyTech
Course

Kotlin for Java Developers

Transfer Java experience to Kotlin through null safety, collections, functions, properties and object contracts. Build a connected multi-file order processor and port a stock ledger.

Java and Kotlin side by side

The same program in Java and in Kotlin, from the lessons of this course.

  1. Strings and Templates

    Kotlin permits top-level functions and starts this standalone file in main without a handwritten class. String templates evaluate a name after a dollar sign or an expression inside braces. Double quotes still delimit strings and single quotes delimit Char…

    Java
    1import java.util.*;2import java.util.function.*;3public class Example {4
    5public static void main(String[] args){6int ready=3;System.out.println("Ready: "+ready);7}8}
    Kotlin
    1
    2fun main(){3val ready=34println("Ready: $ready")5}
  2. Equality and Identity

    Kotlin == invokes null-safe structural equality through equals; === tests reference identity. Java == on references corresponds to the latter. Kotlin does not automatically invent deep equality for every class: ordinary classes still inherit their equals…

    Java
    1import java.util.*;2import java.util.function.*;3public class Example {4
    5public static void main(String[] args){6String a=new String("tea"),b=new String("tea");System.out.println(a==b);7}8}
    Kotlin
    1
    2fun main(){3val a=String(charArrayOf('t','e','a'))4val b=String(charArrayOf('t','e','a'))5println(a==b)6}
  3. Arrays and IntArray

    Kotlin IntArray corresponds to primitive Java int[] on the JVM, while Array<Int> uses the generic object-array representation. Arrays have fixed size and mutable slots. Kotlin provides size, last and lastIndex conveniences rather than changing the underlying…

    Java
    1import java.util.*;2import java.util.function.*;3public class Example {4
    5public static void main(String[] args){6int[] a={4,8,12};System.out.println(a[a.length-1]);7}8}
    Kotlin
    1
    2fun main(){3val a=intArrayOf(4,8,12)4println(a.last())5}
  4. While, Break, and Continue

    Kotlin while repeats while a Boolean condition holds. break exits the nearest loop and continue skips the current iteration. Labeled forms exist for deliberate outer-loop jumps, but ordinary traversal usually needs no label. Progress must remain possible…

    Java
    1import java.util.*;2import java.util.function.*;3public class Example {4
    5public static void main(String[] args){6List<String> kept=new ArrayList<>();for(String word:new String[]{"tea","","STOP","coffee"}){if(word.equals("STOP"))break;if(word.isEmpty())continue;kept.add(word);}System.out.println(String.join(",",kept));7}8}
    Kotlin
    1
    2fun main(){3val kept=mutableListOf<String>()4for(word in listOf("tea","","STOP","coffee")){if(word=="STOP")break;if(word.isEmpty())continue;kept.add(word)}5println(kept.joinToString(","))6}
  5. Top-level Functions

    Kotlin top-level functions do not need a Java utility-class wrapper. Parameters are read-only bindings, and result types may be inferred for expression bodies. A block-bodied non-Unit function needs explicit returns on normal completion paths. A Kotlin…

    Java
    1import java.util.*;2import java.util.function.*;3public class Example {4static boolean isLong(String s){return s.length()>4;}5public static void main(String[] args){6System.out.println(isLong("coffee"));7}8}
    Kotlin
    1fun isLong(text:String):Boolean = text.length>42fun main(){3println(isLong("coffee"))4}
  6. Input and String Formatting

    Kotlin readlnOrNull exposes end-of-input as null, which the locked driver uses to collect lines. String.toInt requires valid complete numeric text; trim explicitly when surrounding whitespace is allowed. Formatting can use JVM locale-aware APIs, so choose…

    Java
    1import java.util.*;2import java.util.function.*;3public class Example {4
    5public static void main(String[] args){6System.out.println("  tea  ".trim().toUpperCase(Locale.ROOT));7}8}
    Kotlin
    1
    2fun main(){3println("  tea  ".trim().uppercase(java.util.Locale.ROOT))4}

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

Final Challenges

2 lessons

More courses for Java developers

Learn Kotlin from another language

Frequently asked questions

Who is Kotlin for Java Developers for?

For people who already write Java and want to learn Kotlin. Each lesson starts from Java you know and shows how Kotlin does the same thing, so you skip the beginner basics.

Do I need to know Kotlin already?

No. The course starts with your first Kotlin program. You need Java basics: variables, conditions, loops, functions and collections.

How many lessons does Kotlin for Java Developers have?

Kotlin for Java Developers contains 48 interactive lessons you can complete at your own pace.

What does Kotlin for Java Developers cover?

The course is organized into chapters covering: Starting Kotlin, Values and Decisions, Collections and Ownership, Iteration and Transformations, and more.

Is Kotlin for Java Developers free?

Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.

Coddy programming languages illustration

Start Kotlin for Java Developers for free

Get started