Online Java compiler, visual debugger, and AI tutor - the only tool that lets you visually debug your Java code step-by-step (also debug Python, JavaScript, C, and C++ code)
Here is a demo. Scroll down to compile and run your own code!
Java
1class Person {
2  private String name;
3  public Person(String theName) {
4    this.name = theName;
5  }
6}
7
8public class Student extends Person {
9  private int id;
10  public static int nextId = 1;
11  public Student(String theName) {
12    super(theName);
13    id = nextId++;
14  }
15
16  public static void main(String[] args) {
17    Person e1 = new Student("Alice");
18    Person e2 = new Student("Bob");
19    Person e3 = new Student("Carol");
20    Person arrayOfPeople[] = {e1, e2, e3};
21  }
22}
line that just executed
next line to execute

Frames
Static fields
Student.nextId4
main:21
e1
 
e2
 
e3
 
arrayOfPeople
 
Objects
Student instance
id1
name"Alice"
Student instance
id2
name"Bob"
Student instance
id3
name"Carol"
array
012
 
 
 
Write code in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public class PKStack {
public static void main(String[] args) {
Stack<Integer> stack = new Stack<>();
int[] A = {4, 8, 15, 16, 23, 42};
for (int i = 0; i < A.length; i++) {
stack.push(A[i]);
}
System.out.println("Stack enthält:");
while (!stack.isEmpty()) {
System.out.print(stack.pop() + " ");
}
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

follow our YouTube, TikTok, Instagram for weekly tutorials

hide all code examples

Java Examples

Basic: Variables | ControlFlow | Sqrt | ExecLimit | Strings

Methods: PassByValue | Recursion | StackOverflow

OOP: Rolex | Person | Complex | Casting

Data structures: LinkedList | StackQueue | Postfix | SymbolTable

Java features: ToString | Reflect | Exception | ExceptionFlow | TwoClasses

Misc: Forest | Knapsack | StaticInitializer | Synthetic

(All Java examples created by David Pritchard)

🤖 Greetings, human! 🤖
I'm a new experimental AI Tutor ready to help you. Your code will be automatically sent to me, so do not copy-paste it into your question.

Ask your question below. Or choose a template, edit it, and click "Send":
AI Tutor may be inaccurate. Scroll up and click Edit and re-send to generate a different AI response.

Tips for good questions:

  • Edit your code to be as small as possible.
  • Be specific and ask about specific parts of your code.
  • Include enough context, such as instructions for your assignment.