Home › coding › java › java collections

Java Collections — Free Java Tutorial

Learn Java Collections in Java with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.

✓ 100% Free ✓ No Login Needed ✓ NCERT / CBSE Aligned ✓ Download as PDF

TL;DR: Learn Java Collections in Java with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.

Written & reviewed by the Syllab.in Academic Team (CBSE/NCERT subject experts) · Updated Jul 14, 2026

🤖 Stuck on any question? Ask Syllab's free AI Tutor for a step-by-step explanation — instant, unlimited, no login.

Java Collections in Java

Java Collections Framework provides pre-built data structures. The most used: ArrayList (dynamic array — like Python list), HashMap (key-value pairs — like Python dict), LinkedList, HashSet, TreeMap.

ArrayList<Type>: A resizable list. Unlike arrays, it grows automatically. Key methods: add(), get(), remove(), size(), contains(), indexOf(), clear(), sort(). Use when you need an ordered, indexed list that can grow.

HashMap<K, V>: Stores key-value pairs with O(1) lookup by key. Key methods: put(), get(), remove(), containsKey(), containsValue(), keySet(), values(), entrySet(). Use when you need fast lookups by key (like a phone book or dictionary).

Java Collections — Syntax

// ArrayList
ArrayList<String> list = new ArrayList<>();
list.add("item");
list.get(0);
list.remove(0);
list.size();

// HashMap
HashMap<String, Integer> map = new HashMap<>();
map.put("Arjun", 85);
map.get("Arjun");       // 85
map.containsKey("key");

Learn Java Collections step by step with Syllab's free interactive Java tutorial — runnable code examples, practice exercises and instant AI feedback, all free with no signup. Explore the full Java course →

Explore:

  • Syllabus
  • Practice
  • Mock Tests
  • NCERT Solutions
  • Coding
  • GK Quiz
  • Career Predictor
  • AI Tutor
  • Live Quiz
  • Doubt Solver
  • Microlearning
  • Free Alternatives
  • Kids Zone
  • Study Room
  • Calculators
  • Worksheets

Syllab.in — Free learning for Indian students, Class 1–12