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.
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…
Java1import 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}Luau1local name = "Ada"2print(`Hi, {name}`)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…
Java1import 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}Luau1local d = {x = nil}2print(d.x == nil)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…
Java1import 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}Luau1local total = 02for i = 1, 3 do total = total + i end3print(total)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…
Java1import 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}Luau1local function twice(x: number): number return x * 2 end2print(twice(4))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…
Java1import 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}Luau1local a = {"a", "b", "c"}2table.remove(a, 2)3print(table.concat(a, ","))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…
Java1import 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}Luau1local a={3,1,2}2table.sort(a)3print(a[1])
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsFirst Luau Programs
6 lessonsValues and Decisions
5 lessonsIteration and Flow
5 lessonsFunctions and Closures
5 lessonsTables as Collections
5 lessonsOrdering, Modules and Errors
5 lessonsObjects and Owned State
5 lessonsComposition and Object Lookup
6 lessonsProject: Stock Ledger
4 lessonsFinal Source Ports
2 lessonsFrequently 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.