This tool is going to be useful to you when we start getting into classes and instances.

The tool was originally created for Python, hence the name Python Tutor.

However, it has been extended to Java.

You are encouraged to play around with it when we start exploring new concepts.

This guide is to help you get started, as you might need to tweak the code you give it in order to get it to work.




Running the Java visualiser with your own code snippets

Go to the Python Tutor for Java website.

You should see something like this:

Python Tutor for Java


Scroll down until you see the “Write code in” section, and make sure that “Java” is selected:

Python Tutor for Java


Let’s say we want to visualise the code provided in our Pokemon example from the OOP Thought Process page:

Python Tutor for Java


Copy the entire code from our Main.java file:

Python Tutor for Java


Now paste it into Python Tutor, but make sure you add public in front of the class name:

Python Tutor for Java


Go back to our Repl, click on the “Show Files” button, and copy the code from the Pokemon.java file:

Python Tutor for Java


Since we are pasting all out code into the same section, Python Tutor will complain if we don’t have exactly one public class.

We therefore need to remove the public keyword from the Pokemon class when we paste it into Python Tutor, at the end of where we pasted the Main class:

Python Tutor for Java


Now scroll to the bottom of the page and click on the “Visualize Execution” button:

Python Tutor for Java


If all goes well, you should see something like this:

Python Tutor for Java


You can now click on the control buttons to step through the code, and see how everything changes:

Python Tutor for Java


There is also a “Get AI Help” button, which will try and help you with your code:

Python Tutor for Java


What is does is generate the prompt that you can then copy-paste into ChatGPT to get an explanation or ask further questions.







Try and follow the same approach when using other code that you want to visualise.

The main thing to remember is that you can only have one public class.