#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
☕ FREE · 40 SNIPPETS

Java Cheat Sheet: Core Java on One Page

The Java syntax and APIs you reach for most, searchable and ready to copy.

  • 🧱 OOP and records
  • 🗂️ Collections
  • 🌊 Streams

How to use the Java Cheat Sheet

  1. 1. Search or browseType a word like the function or task you need, or pick a section.
  2. 2. CopyEach snippet has its own Copy button, so you can paste it straight into your editor.
  3. 3. DownloadSave the whole Java cheat sheet as plain text or Markdown for offline revision.

What's in it

It covers modern Java (17 and later), including switch expressions, records and pattern matching for instanceof. The 40 snippets are organised into 10 sections: Basics, Strings, Arrays, Control flow, OOP, Exceptions, Collections, Streams, Input/Output, Tools.

Example

Search "string" to see why s.equals(t) is used instead of ==, and how new StringBuilder(s).reverse() reverses text. In the Streams section, IntStream.rangeClosed(1, 5).sum() gives 15, and Collectors.groupingBy(String::length) groups words by length.

Tips for using it

  • Pair it with the Java practice problems; look up syntax here while you solve them.
  • Learn the difference between List.of (immutable) and new ArrayList<>(List.of(…)) (mutable).

A quick look, one snippet per section

  • Basics: public static void main(String[] args) { } (program entry point)
  • Strings: s.length(), s.charAt(0), s.substring(1, 4) (length, a character, part of a string)
  • Arrays: int[] a = {5, 2, 8}; Arrays.sort(a); (sort an array)
  • Control flow: for (int i = 0; i < n; i++) { } (counting loop)
  • OOP: class Car extends Vehicle implements Comparable<Car> { } (inherit and implement)
  • Exceptions: try { ... } catch (IOException e) { ... } finally { ... } (handle exceptions)
  • Collections: List<Integer> l = new ArrayList<>(List.of(3, 1, 2)); (mutable list from values)
  • Streams: l.stream().filter(x -> x > 1).map(x -> x * 2).toList(); (filter and transform (toList in Java 16+))
  • Input/Output: Scanner sc = new Scanner(System.in); int n = sc.nextInt(); (read input)

Search the box above for the rest of the Java snippets, or download the full sheet.

Frequently asked questions

Which Java version?

Java 17 LTS and later; a few snippets note when a feature arrived.

Is there a separate collections sheet?

Yes. The Java Collections cheat sheet goes deeper.

Is the Java cheat sheet free?

Yes. You can search, read and copy every snippet in the Java cheat sheet without signing up. The first time you download it, we ask once for your name and WhatsApp number; after that downloads and every other Uncodemy tool open straight away.

More free tools

See all free tools