Here's all the major new Java visualizer features we added in 2026. Most notably, it now runs Java 25 instead of Java 8, and it runs your code several times faster.
We recommend Java 25 since it has new features and is optimized to run faster than Java 8. Links made before this update now run on Java 25 too. If one of them doesn't look right (e.g., if it opens at a different step), you can still run Java 8 by clicking "Edit this code" and choosing "Java 8 (old version) [unsupported]".
For what the visualizer could already do, see How the Python Tutor visualizer can help students in your Java programming courses.
User input with Scanner
- Programs can now read user input with
Scanner(nextInt,nextLine,hasNextInt, etc). Your inputs are listed under "User inputs" for you to edit and re-run, and they're also saved in shared links. see it - Wrong input, like
abcfornextInt(), shows anInputMismatchExceptionon the line that read it, with the method calls that led there. see it
Newly-rendered data structures and objects
ArrayList,LinkedList,HashMap,TreeMap,LinkedHashMap,HashSet,TreeSet, andLinkedHashSetshow their contents. Before, they were drawn as opaque labels like "ArrayList object". see itStack,ArrayDeque, andPriorityQueueshow their contents, with the top of the stack, the front and back of the queue, and the head of the priority queue marked. Before, they were drawn as empty boxes. see itStringBuildershows its text. see it- 2-D arrays are drawn as grids instead of as an array of arrows to other arrays. (Uncheck "show array-of-arrays as 2D array" under the code editor to get the old view back.) see it
- Wrapper types like
IntegerandDoubleare drawn as boxed values, so they look different fromintanddouble. see it BigIntegerandBigDecimalshow their values. see it- Exception objects show their message. see it
Java 25's simpler syntax for beginners
The visualizer now runs Java 25 (first released in 2025) by default.
Most notably, it simplifies teaching by letting users write code without
defining a class (it just needs a main method) and use IO.println
to print. Other methods can go outside of any class too, like square
here:
Here at Step 17, square(3) is about to return 9 to main, where
total is 5 from the first two calls.
Similarly, IO.readln prints a prompt and reads one line of user input
so users don't need to create a Scanner object:
Here at Step 2, IO.readln has read the first line the user typed,
Ada, which is crossed out under "User input processed so far". Note
that the output shows Ada after the prompt, as it would in a terminal.
Then the next line reads 36 and crosses it out when the code has
processed it.
Newer Java language features
The old Java 8 visualizer (released in 2014) couldn't run code that uses newer features of the language, but now Java 25 supports them. For instance:
varfor local variables. see itswitchexpressions with->arrows. see it- Text blocks for strings that span several lines. see it
- Records, which are drawn as objects with their fields. see it
- Pattern matching with
instanceof. see it - Sealed interfaces and
switchon types, including record patterns. see it - Unnamed variables written as
_. see it - Statements before
super(...)in a constructor. see it import module java.base;to import everything in one line. see it- Newer library methods such as
List.of,getFirst,getLast,repeat,strip,isBlank, andstream().toList(). see it - Clearer exception messages from Java 25, such as
Index 3 out of bounds for length 3instead of just3. see it
Fewer restrictions on how to write your code
- The class with
maindoesn't need to bepublic. Before, the visualizer said "Make sure your code includes 'public class «ClassName»'". see it - Several
publicclasses can go in one file, such as a textbook'sBankAccountandBankAccountTest. Before, only one class could bepublic, so you had to deletepublicfrom the others. The firstpublicclass with amainmethod runs. see it - A
packageline at the top works now. Before, it gave a confusing "server may be overloaded" error. see it - Your own classes can be named
Point,Stack,Queue, and so on. Before, these names clashed with an old Princeton library that came bundled with the visualizer. see it or a class namedStack. import java.util.*;gives you Java's ownStackandQueue. Before, it gave you the Princeton library's versions instead, so code likeQueue<String> line = new LinkedList<>();didn't compile, and you had to writeimport java.util.Stack;andimport java.util.Queue;. see itmain(String... args)and the other ways to writemainthat Java allows. see it- A missing
importgets a hint, such asAdd "import java.util.Scanner;" at the top of your file.see it
Java 8 is still available
If you need the old Java 8 choose "Java 8 (old version) [unsupported]"
from the language menu. Programs that use the Princeton library
(StdOut, StdIn, StdDraw, ...) need Java 8, since that library no
longer comes with the visualizer.
Remaining limitations
- Programs can't read files, start threads, or open windows or dialogs. see it
- There's no way to signal the end of user input, so
while (sc.hasNextLine())keeps asking for more input. see it - What a program prints to
System.errisn't shown. see it Scanner,Random,Iterator, and some other library objects are drawn as empty boxes. see it- Variables don't show their declared types, only the type of the object they point to, so
Animal pet = new Dog("Rex", 3);shows only aDog. Fields don't showpublic,protected, orprivateeither. see it - A class that extends a library class, like
ArrayList, doesn't show its internal contents. see it - A
NullPointerExceptiondoesn't say which variable wasnull. see it - Lambdas have names that the compiler made up, like
lambda$main$0. see it