Menu
CoddyTech
Course

Luau for Java Developers

Transfer Java collections, lambdas and classes to Luau tables, closures and typed signatures. Practice runtime validation, relative modules and metatable objects, build a stock ledger and port two Java programs.

Java and Luau side by side

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

  1. Print and Comment

    Java System.out.println prints one value, while formatting and concatenation assemble more complex text. Luau print separates multiple arguments with tabs, so build one string with .. when exact spacing matters. Luau chunks need no Main class or main method…

    Java
    1import java.util.*;2import java.util.function.*;3import java.util.regex.*;4public class Main {5
    6public static void main(String[] args) throws Exception {7System.out.println("Hi"+", Ada");8}9}
    Luau
    1local name = "Ada"2print(`Hi, {name}`)
  2. Missing Fields and Optionals

    A Java HashMap can retain a key mapped to null; containsKey distinguishes that association from absence. Luau nil removes a table field. A number? annotation describes possible absence but cannot preserve a nil-valued entry. Use a separate flag or tagged…

    Java
    1import java.util.*;2import java.util.function.*;3import java.util.regex.*;4public class Main {5
    6public static void main(String[] args) throws Exception {7Map<String,Integer> record=new HashMap<>(); record.put("x",null); System.out.println(record.containsKey("x"));8}9}
    Luau
    1local d = {x = nil}2print(d.x == nil)
  3. Inclusive Numeric Loops

    Java counted loops commonly stop at an exclusive upper bound. Luau numeric for includes its final bound and accepts an optional step. Translate the actual visited values, including descending and empty cases. Keeping the old exclusive endpoint can add an…

    Java
    1import java.util.*;2import java.util.function.*;3import java.util.regex.*;4public class Main {5
    6public static void main(String[] args) throws Exception {7int total=0; for(int i=1;i<4;i++) total+=i; System.out.println(total);8}9}
    Luau
    1local total = 02for i = 1, 3 do total = total + i end3print(total)
  4. Functions and Returns

    Java passes argument values, including object references; rebinding a parameter does not rebind the caller’s variable. Luau behaves similarly for scalars and shared table references. Typed signatures describe intent, but this runner does not run the analyzer…

    Java
    1import java.util.*;2import java.util.function.*;3import java.util.regex.*;4public class Main {5static int twice(int x){return x*2;}6public static void main(String[] args) throws Exception {7System.out.println(twice(4));8}9}
    Luau
    1local function twice(x: number): number return x * 2 end2print(twice(4))
  5. Lists as Dense Tables

    Java arrays have fixed length and ArrayList manages a growable sequence with zero-based removal. Luau dense tables start at one and table.remove shifts later elements. Assigning nil creates a hole. Sequence length is not the count of arbitrary dictionary…

    Java
    1import java.util.*;2import java.util.function.*;3import java.util.regex.*;4public class Main {5
    6public static void main(String[] args) throws Exception {7List<String> values=new ArrayList<>(List.of("a","b","c")); values.remove(1); System.out.println(String.join(",",values));8}9}
    Luau
    1local a = {"a", "b", "c"}2table.remove(a, 2)3print(table.concat(a, ","))
  6. Sorting and Comparators

    Java Comparator.compare returns a negative, zero or positive integer. Luau table.sort expects a Boolean strict ordering predicate and mutates the table. Returning a difference is wrong because zero is truthy. Retain the table reference rather than assigning…

    Java
    1import java.util.*;2import java.util.function.*;3import java.util.regex.*;4public class Main {5
    6public static void main(String[] args) throws Exception {7List<Integer> values=new ArrayList<>(List.of(3,1,2)); values.sort(Integer::compare); System.out.println(values.get(0));8}9}
    Luau
    1local a={3,1,2}2table.sort(a)3print(a[1])

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

Final Source Ports

2 lessons

More courses for Java developers

Learn Luau from another language

Frequently asked questions

Who is Luau for Java Developers for?

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

Do I need to know Luau already?

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

How many lessons does Luau for Java Developers have?

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

What does Luau for Java Developers cover?

The course is organized into chapters covering: First Luau Programs, Values and Decisions, Iteration and Flow, Functions and Closures, and more.

Is Luau 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 Luau for Java Developers for free

Get started