Menu
CoddyTech
Course

Java for Luau Developers

Transfer Luau experience to Java through explicit types, collections, methods and object contracts. Build a connected multi-file order processor and port a stock ledger.

Luau and Java side by side

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

  1. Strings and Output

    Luau runs top-level chunk statements through its host, while these Java 17 examples enter a class’s static main method. Luau print separates arguments with tabs; Java println accepts one value and appends a newline. Build a full string with Java concatenation…

    Luau
    1local name="Ada"; print("Hi "..name.."!")
    Java
    1import java.util.*;2import java.util.function.*;3import java.util.stream.*;4public class Example {5
    6public static void main(String[] args) {7String name="Ada";System.out.println("Hi "+name+"!");8}9}
  2. String Equality

    Luau string equality compares byte contents, while table equality normally uses identity unless a metatable supplies behavior. Java String == compares reference identity; use equals for text and Objects.equals when null is possible. Interned Java literals can…

    Luau
    1local a="ab"; local b="a".."b"; print(a==b)
    Java
    1import java.util.*;2import java.util.function.*;3import java.util.stream.*;4public class Example {5
    6public static void main(String[] args) {7String a=new String("ab"),b=new String("ab");System.out.println(a.equals(b));System.out.println(a==b);8}9}
  3. Fixed-size Arrays

    A Luau {number} annotation describes an array-like table but does not fix its runtime length or give it Java array storage. Sequence holes affect # and traversal, and negative keys do not automatically count from the end. Java arrays have a fixed length, a…

    Luau
    1local values:{number}={2,4,6}; print(values[#values])
    Java
    1import java.util.*;2import java.util.function.*;3import java.util.stream.*;4public class Example {5
    6public static void main(String[] args) {7int[]a={2,4,6};System.out.println(a[a.length-1]);8}9}
  4. While and Early Exit

    Luau and Java both support break and continue in loops. Java requires Boolean conditions, while Luau also permits truthiness and its checker can refine types in branches. Ensure every continuing path advances a manual index. Break exits the loop entirely and…

    Luau
    1local n:number=3; while n>1 do n-=1 end; print(n)
    Java
    1import java.util.*;2public class Example {3public static void main(String[] args) {4List<String> kept=new ArrayList<>();5for(String word:new String[]{"tea","","STOP","coffee"}) {6    if(word.equals("STOP")) break;7    if(word.isEmpty()) continue;8    kept.add(word);9}10System.out.println(String.join(",",kept));11}12}
  5. Static Methods and Returns

    Luau functions can be local values, module fields and explicitly typed callbacks. Java methods belong to classes and distinguish static helpers from instance behavior. Declare Java result types and return on every normal path of a non-void method. Passing an…

    Luau
    1local function hours(total:number):number return total//60 end; print(hours(125))
    Java
    1import java.util.*;2import java.util.function.*;3import java.util.stream.*;4public class Example {5static int hours(int total){return total/60;}6public static void main(String[] args) {7System.out.println(hours(125));8}9}
  6. Input and Exact Formatting

    Luau io.read can read lines or numeric input, while the Java driver reads lines and passes them into your method. Java Integer.parseInt does not automatically trim surrounding whitespace, so normalize only what the contract permits. Luau string.format and…

    Luau
    1local cents=305; print(string.format("tea: %d.%02d",cents//100,cents%100))
    Java
    1import java.util.*;2import java.util.function.*;3import java.util.stream.*;4public class Example {5
    6public static void main(String[] args) {7int cents=305;System.out.println(String.format(Locale.ROOT,"tea: %d.%02d",cents/100,cents%100));8}9}

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

Final Challenges

2 lessons

More courses for Luau developers

Learn Java from another language

Frequently asked questions

Who is Java for Luau Developers for?

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

Do I need to know Java already?

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

How many lessons does Java for Luau Developers have?

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

What does Java for Luau Developers cover?

The course is organized into chapters covering: Getting Started in Java, Values and Decisions, Collections and References, Iteration and Pipelines, and more.

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

Get started