When my code gave the wrong output, all I could do was add more print statements. So I built WriteCode : a free online compiler that also lets you debug and see your code run step by step .
What you can do
βΆοΈ Run code : Java, Python, C, C++, JavaScript, SQL and more
β¨οΈ Type input while the program runs, like a real terminal
π Debug : set breakpoints and step through line by line
π Visualize : arrays, linked lists, trees and recursion drawn as they change
ποΈ Real MySQL for SQL practice
No sign-up. Works on phones too.
Try this
Paste this Java code, then press Visualize :
public class Main { static class Node { int val ; Node next ; Node ( int val ) { this . val = val ; } }
public static void main ( String [ ] args ) { Node head = new Node ( 1 ) ; head . next = new Node ( 2 ) ; head . next . next = new Node ( 3 ) ;
Node prev = null , cur = head ; while ( cur != null ) { Node next = cur . next ; cur .β¦