Skip to content

About

It is the MK Code Club's Java Collections Framework Course Repository.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Java Collections Framework

A practical collection of Java exercises from the MK Code Club channel

This repository contains the hands-on code examples used to teach the Java Collections Framework on the MK Code Club channel. Each lesson is a small, focused Java program that can be compiled and run independently, making it easy to follow along, experiment, and compare collection types.

The examples move from everyday list operations to sets, maps, stacks, queues, and useful helper methods from the Collections class.


What You Will Learn

  • How to create, read, update, delete, and traverse collections
  • The difference between ordered, sorted, and unordered collections
  • How collections handle duplicate values
  • How to store key-value pairs with maps
  • How stack and queue data structures work
  • How to use common methods from java.util.Collections
  • How to choose a collection based on the behavior your program needs

Course Roadmap

Lesson File Main topic Concepts demonstrated
1 T1_ArrayList.java ArrayList Add, read, update, remove, size, indexed traversal
2 T2_LinkedList.java LinkedList Basic list operations plus first/last element methods
3 T3_HashSet.java HashSet Unique values, remove, contains, size, clear
4 T4_LinkedHashSet.java LinkedHashSet Unique values with insertion order preserved
5 T5_TreeSet.java TreeSet Unique values maintained in sorted order
6 T6_HashMap.java HashMap Key-value storage, lookup, key traversal, removal
7 T7_LinkedHashMap.java LinkedHashMap Key-value storage with insertion order preserved
8 T8_TreeMap.java TreeMap Key-value storage with keys kept sorted
9 T9_Stack.java Stack LIFO behavior with push, pop, and peek
10 T10_Queue.java Queue FIFO behavior with offer, poll, and peek
11 T11_Important_Methods.java Collections utilities Sort, reverse sort, swap, frequency, min, max, binary search

Collection Quick Guide

Lists

Lists keep elements in a sequence and allow duplicate values.

Collection Best known for Ordering
ArrayList Fast indexed access and general-purpose lists Insertion order
LinkedList Adding or removing elements at the beginning or end Insertion order

Sets

Sets store unique values and do not allow duplicates.

Collection Best known for Ordering
HashSet Fast general-purpose uniqueness checks No guaranteed iteration order
LinkedHashSet Uniqueness while retaining insertion order Insertion order
TreeSet Uniqueness with automatic sorting Sorted order

Maps

Maps associate a unique key with a value.

Collection Best known for Key ordering
HashMap Fast general-purpose key-value lookup No guaranteed iteration order
LinkedHashMap Key-value lookup while retaining insertion order Insertion order
TreeMap Key-value lookup with sorted keys Sorted order

Special-purpose structures

  • Stack: Last In, First Out (LIFO). The most recently added item is removed first.
  • Queue: First In, First Out (FIFO). The earliest added item is removed first.

Requirements

  • Java Development Kit (JDK) 8 or newer
  • A terminal, command prompt, or Java-compatible IDE

No third-party libraries, build tools, or database setup are required. Every example uses classes from the standard Java library.

Check your Java installation with:

java -version
javac -version

Run an Exercise

Open a terminal in the repository directory and compile the file you want to explore:

javac T1_ArrayList.java
java T1_ArrayList

Replace T1_ArrayList with any class name from the course roadmap.

Compile every exercise

On macOS or Linux:

javac *.java

On Windows PowerShell:

javac *.java

Run any compiled lesson, for example:

java T8_TreeMap

To remove generated bytecode files after experimenting:

Remove-Item *.class

On macOS or Linux, use:

rm *.class

Suggested Learning Path

  1. Start with ArrayList and LinkedList to understand sequence-based collections.
  2. Compare HashSet, LinkedHashSet, and TreeSet to see how uniqueness and ordering differ.
  3. Practice key-value operations with HashMap, LinkedHashMap, and TreeMap.
  4. Learn LIFO and FIFO behavior with Stack and Queue.
  5. Finish with T11_Important_Methods.java and apply utility methods to a list.
  6. Modify the values, add new elements, and predict the output before running each program.

Practice Challenges

After completing the examples, try these small extensions:

  • Change the examples from Integer values to String values.
  • Add duplicate values and observe how lists and sets respond differently.
  • Insert map entries in a different order and compare HashMap, LinkedHashMap, and TreeMap.
  • Add a for-each loop to every collection example.
  • Add a containsValue check to the map examples.
  • Build a simple task manager using a Queue.
  • Build a browser-history simulation using a stack.
  • Sort a custom list in ascending and descending order.

Repository Structure

java-collections-course/
├── T1_ArrayList.java
├── T2_LinkedList.java
├── T3_HashSet.java
├── T4_LinkedHashSet.java
├── T5_TreeSet.java
├── T6_HashMap.java
├── T7_LinkedHashMap.java
├── T8_TreeMap.java
├── T9_Stack.java
├── T10_Queue.java
├── T11_Important_Methods.java
└── readme.md

About MK Code Club

This repository is a companion learning resource for the MK Code Club channel. The examples are intentionally simple and readable so that beginners can focus on the behavior of each collection, then build on the examples with their own experiments.

Learn by running the code, changing the code, and checking whether the output matches your prediction.


License

This repository is provided for learning and educational purposes.

About

It is the MK Code Club's Java Collections Framework Course Repository.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages