Write a complete Java program, then step through its variables, object references and method calls. Select Java in the visualizer, paste a full example below and run it, or explore it directly on this page.
public static void main(String[] args) entrypoint. The examples use Main; your entry class may have a different name.main. Interactive input is not supported.Main. Nested classes, including static class ListNode, are not supported.import statements for supported standard-library classes. Do not add a package declaration. Maven, Gradle and external dependencies are not available.ListNode, TreeNode, buildLinkedList or buildTree helpers. Define your node types and construct the links in the same source file, as shown below.Choose a tab to inspect each complete program. Use the playback controls to move through its execution.
| Example | What to observe |
|---|---|
| Basics | result becomes 3 inside main. |
| Arrays | total becomes 12 and matrix[0][1] changes to 12. |
| Recursion | Nested calls to factorial return 120. |
| Linked list | Three source-defined nodes share links; traversal produces total = 60. |
| Binary tree | Recursive calls follow the child references and produce result = 12. |
| Collections | List updates, mapping entries and set deduplication produce count = 6. |
BigInteger, null, one-dimensional and multidimensional arrays.finally and automatic resource closing.ArrayList, LinkedList, Arrays.asList, List.of, HashMap, LinkedHashMap, HashSet and LinkedHashSet. Other library objects may remain visible without expandable contents.LinkedHashMap and LinkedHashSet preserve insertion order; do not rely on HashMap or HashSet iteration order. A source-defined subclass of a library collection displays its source fields rather than combining them with the library's private collection storage.
Java support covers single-threaded algorithm visualization, not every Java feature or standard-library type. Packages, nested/local/anonymous classes, records, lambdas, method references, pattern bindings, user-defined native methods, reflection, dynamic loading and launching other processes are not supported. Executing your source methods on another thread stops the run with a diagnostic.
Keep inputs small enough to inspect step by step. Execution and visualization limits still apply; if a run reaches a limit, reduce the input size. Compilation or runtime errors should be corrected at the reported source location. Printing is not required to observe variables or return values.
See the general usage guide for troubleshooting.