ZAK's Java Playground
Real Java, compiled and run inside your browser — nothing to install, nothing sent to a server. Write the program, put what Scanner should read in the input box, press Run and get the output, any files it wrote, the JDK's own error messages and a line-by-line trace table. The Examples mirror the Python Playground; switch the toggle to compare a program in pseudocode, Python, Java and VB.NET.
Java example library
72 programs — the same categories as the pseudocode and Python libraries, written the way Paper 4 expects them.
Basics & data types 9
Variables, constants, INPUT/OUTPUT, arithmetic, DIV/MOD, conversions
Selection 4
IF/ELSE, nested IF, CASE with lists and ranges, Boolean conditions
Iteration 5
FOR, WHILE, REPEAT, nested loops, totalling, counting, max/min
String handling 7
LENGTH, SUBSTRING/MID, UCASE/LCASE, ASC/CHR, reversing, palindromes, ciphers
Arrays 5
1D and 2D arrays, parallel arrays, whole-array copy, frequency counts
Procedures & functions 5
Parameters, RETURN, BYREF vs BYVAL, scope, stepwise refinement
Validation, testing & exceptions 6
Range, length, type, format and check-digit checks; verification; test data; trace tables; TRY … EXCEPT
Searching 3
Linear search, binary search (iterative and recursive), comparing efficiency
Sorting 3
Bubble sort (with and without a flag), insertion sort, sorting strings and parallel arrays
File handling 4
Text files (READ/WRITE/APPEND, EOF), delimited records, random-access files
Records & user-defined types 2
TYPE…ENDTYPE records, arrays of records, enumerated, pointer and set types, DATE
Stacks, queues, lists & trees 5
Stack, linear and circular queue, linked list, binary search tree, hash table, dictionary
Recursion 2
Base and general cases, winding/unwinding, factorial, Fibonacci, GCD, Hanoi
Object-oriented programming 5
Classes, constructors, encapsulation, inheritance, polymorphism, containment
Theory in code 4
Number bases, two's complement, parity, logic gates, adders, FDE cycle, compression, floating point, RPN, graphs
Exam-style tasks 3
Complete scenario programs in the style of 2210 Section B, 9618 Paper 2 and Paper 4
How the Java Playground works
- It is the real Java compiler. OpenJDK's javac checks your program, so the compile errors are the ones you would see in an IDE or the exam room — each with a plain-English hint. TeaVM then turns the bytecode into WebAssembly, and it runs in your browser.
- Input: Scanner (nextLine, nextInt, hasNextInt …) and BufferedReader read the input box one line at a time, echoed like a terminal. The nextInt()-then-nextLine() surprise happens here exactly as in real Java.
- Files (FileWriter, PrintWriter, BufferedReader, Scanner(new File(…))) live in a folder that starts empty on every run; whatever the program writes is shown under the output.
- Run-time errors are the JDK's own: ArithmeticException: / by zero, Index 5 out of bounds for length 3, helpful NullPointerException messages that name the variable, and a stack trace with your line numbers.
- Trace table: every change to a local variable, line by line, including inside methods and recursion.
- Infinite loops stop after 8 seconds, with the line the program was on. Desktop-only parts of Java (Swing, JavaFX, threads, the network) are not available; Thread.sleep pauses for at most 1.5 seconds.
- First use downloads about 8 MB (cached afterwards). It needs a current browser: Chrome or Edge 137+, Firefox 131+, Safari 18.4+.


