100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

Java Cheat Sheet

Java Cheat Sheet

Core Java syntax, data types, collections, generics, and streams for writing robust object-oriented JVM applications.

2 PagesBeginnerApr 15, 2026

Basic Syntax

Variables, control flow, and loops.

java
public class Main {    public static void main(String[] args) {        int age = 30;              // primitive int        String name = "Ada";       // reference type        double pi = 3.14159;        boolean isJavaFun = true;        if (age >= 18) {            System.out.println(name + " is an adult");        } else {            System.out.println(name + " is a minor");        }        for (int i = 0; i < 5; i++) {            System.out.println("Count: " + i);        }    }}

Collections Framework

Lists, maps, and sets from java.util.

java
List<String> names = new ArrayList<>();names.add("Alice");names.add("Bob");names.get(0);              // "Alice"names.remove("Bob");Map<String, Integer> ages = new HashMap<>();ages.put("Alice", 30);ages.getOrDefault("Bob", 0);   // 0ages.containsKey("Alice");     // trueSet<Integer> unique = new HashSet<>(List.of(1, 2, 2, 3)); // {1, 2, 3}

Streams API

Functional-style collection processing.

java
List<Integer> nums = List.of(1, 2, 3, 4, 5, 6);List<Integer> evens = nums.stream()    .filter(n -> n % 2 == 0)    .map(n -> n * n)    .collect(Collectors.toList());   // [4, 16, 36]int sum = nums.stream().mapToInt(Integer::intValue).sum(); // 21Optional<Integer> max = nums.stream().max(Integer::compareTo);

OOP Keywords

Core keywords for object-oriented Java.

  • extends- inherits from a superclass (single inheritance)
  • implements- implements one or more interfaces
  • @Override- annotation marking a method that overrides a superclass/interface method
  • abstract- declares a class or method with no full implementation
  • final- prevents further subclassing, overriding, or reassignment
  • static- belongs to the class rather than an instance
  • interface- defines a contract of methods a class must implement
  • try/catch/finally- exception handling; finally always runs
Pro Tip

Prefer List.of() and Map.of() for immutable collections in modern Java (9+) instead of manually wrapping with Collections.unmodifiableList().

Was this cheat sheet helpful?

Explore Topics

#Java#JavaCheatSheet#Programming#Beginner#BasicSyntax#CollectionsFramework#StreamsAPI#OOPKeywords#OOP#DataStructures#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech

Professional Web Designing Services

  • Responsive Websites
  • E-commerce Solutions
  • SEO Friendly Design
  • Fast & Secure
  • Support & Maintenance
Get a Free Quote

Share this Cheat Sheet