DSA Tracker

DSA Tracker

New to DSA in Java? Start with the basics

Java compiler

OpenJDK 17/21, runs on our server

main.java
Press Run and what your code prints shows up here.

Java online compiler and code runner

Run Java programs in your browser with zero setup. Write classes, test algorithms with `java.util.*`, and execute standard Java code directly.

Can I use Java Collections and Streams in this online compiler?

Yes. The compiler supports the full Java Collections Framework, allowing you to use ArrayList, HashMap, HashSet, PriorityQueue, and Streams.

Can I take user input in this online Java compiler?

Yes. Enter your custom input in the stdin box before running your code, and read it using Scanner or BufferedReader.

Popular Java examples

Scanner User Input

Reading integers and strings using java.util.Scanner.

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter your name: ");
        if (sc.hasNext()) {
            System.out.println("Welcome, " + sc.next() + "!");
        }
    }
}

Ready to practise real interview problems in Java?

Solve 370 curated problems merged from Striver A2Z, Love Babbar 450 and Apna College, with no duplicate questions.

Questions people ask

What should be the main class name?

Name your public class `Main` with the standard `public static void main(String[] args)` signature.

Can I run Java programs online without installing the JDK?

Yes. You can compile and run Java programs directly in your browser without downloading the JDK or setting environment variables. The compiler is free and ready to use immediately.

Which Java version runs here and what libraries are supported?

The environment runs modern OpenJDK runtimes, including OpenJDK 17 and 21. Standard Java libraries such as `java.util`, `java.io`, `java.math`, and the Stream API are available.

How do I pass user input to a Java program?

Click on the Input tab next to the console output to enter test data before running your code. Inside your Java program, read standard input using `java.util.Scanner` with `System.in` or `BufferedReader`. The runner feeds this text directly to stdin.

What are the execution limits for Java code?

Execution is capped at a CPU limit of 5 seconds and a wall-clock limit of 10 seconds per run. Programs run in an isolated sandbox with no outbound network access or persistent file storage. Code size must be under 20,000 characters and input under 4,000 characters.

Can I practice coding interview problems in Java here?

Yes. 356 of the 370 curated interview problems on DSA Tracker are graded on hidden test cases in Java. You can write your solution inside the problem workspace and submit it for automated grading.

Do I need to create an account to use the Java compiler?

No account or sign-in is required to compile and run Java code. An account is only needed if you want to track your problem progress or use monthly AI assistance credits.

Writing DSA solutions in Java: what trips people up

Small facts about Java that decide whether an interview solution passes or times out.

  • Scanner is slow on big input

    Read with BufferedReader and break lines into numbers with StringTokenizer; String.split builds a regex and an array for every line, which adds up on large input.

  • Compare boxed numbers with equals

    == on two Integer objects compares references, which works only for small cached values. Use equals or unbox to int first.

  • Build strings with StringBuilder

    Strings are immutable, so += in a loop copies the whole string each time. StringBuilder appends in place.

  • PriorityQueue is a min-heap

    Pass Collections.reverseOrder() or a comparator for a max-heap. ArrayDeque is the fast choice for both stacks and queues.

  • Watch int overflow

    int is 32 bits. Use long for sums and products, and Math.addExact when an overflow should fail loudly.