AI Instructor Live Labs Included

Java Data Structures and Collections

Master Java collections and data structures by building an Inventory Management System. Covers arrays, ArrayList, HashMap, generics, sorting, and streams through 14 paired lessons.

Beginner
17h 35m
14 Lessons
SMU-JAVA-DSA
Java Data Structures and OOP Badge

View badge details

About This Course

A deep dive into Java's collections framework and data structures for developers who have completed Java Programming Fundamentals. Through 14 guided lessons, you'll build a complete Inventory Management System console application starting with raw arrays and progressively migrating to ArrayList, HashMap, HashSet, generics, sorting with Comparator, and stream-based reporting. Each teaching lesson is paired with hands-on coding exercises in VS Code using JDK 21 and Maven.

Course Curriculum

14 Lessons
01
AI Lesson
AI Lesson

Arrays and Iteration Patterns

45m

Learn Java array fundamentals: fixed-size arrays, array initialization, traversal with for and for-each loops, linear search, manual size tracking, and why fixed arrays lead naturally to ArrayList. All examples use the Inventory Management System context.

02
Lab Exercise
Lab Exercise

Arrays - Lab Exercises

1h 30m 3 Exercises

Hands-on exercises to traverse a Product[] array using for and for-each loops, implement linear search in InventorySearch.java, and add a product to the array while handling overflow.

Traverse and Display the Catalog Open Main.java. Use a for loop with an index to print each product with its position number (1-based). Then use a for-each loop to print only products where quantity < 10 (low stock). ~15 min
Implement Linear Search Open InventorySearch.java (exists with TODO). Implement findById(Product[] catalog, int count, String id) returning the matching Product or null. Implement findAllByCategory returning a new Product[] with matching items. Test both from Main.java. ~15 min
Add a Product to the Array In Main.java, add a method addProduct(Product[] catalog, int count, Product p) returning the new count. Demonstrate what happens when count >= catalog.length by printing a clear error message. Add 3 more products and print the full catalog again. ~15 min
03
AI Lesson
AI Lesson

ArrayList and LinkedList

45m

Learn ArrayList internals and core operations, safe bulk removal with removeIf, LinkedList for FIFO/deque operations, ArrayList vs LinkedList performance trade-offs, and ConcurrentModificationException prevention.

04
Lab Exercise
Lab Exercise

ArrayList - Lab Exercises

1h 30m 3 Exercises

Hands-on exercises to replace the Product[] array with ArrayList in InventoryStore, add safe bulk operations with removeIf, and implement a LinkedList-based search history.

Replace the Array with ArrayList Open InventoryStore.java. Initialize products as new ArrayList<>(). Implement addProduct(Product p), removeProduct(String id) using removeIf, getProduct(String id) using a for-each loop, and getAllProducts() returning an unmodifiable view. ~15 min
Safe Bulk Operations Add removeOutOfStock() using removeIf(p -> p.getQuantity() == 0). Add getProductsByCategory(String category) returning a new ArrayList of matching products. Update Main.java to use InventoryStore instead of the raw array. ~15 min
LinkedList as a Search History Add a LinkedList<String> searchHistory field to InventoryStore. After every getProduct() call, prepend the searched ID using addFirst(). Cap the list at 10 entries using removeLast(). Add getSearchHistory() and display it in the main menu. ~15 min
05
AI Lesson
AI Lesson

Maps and Sets

45m

Learn HashMap O(1) key-value operations, iterating Maps with entrySet, grouping with Map>, HashSet for uniqueness, LinkedHashMap and TreeMap, and common Map pitfalls.

06
Lab Exercise
Lab Exercise

Maps and Sets - Lab Exercises

1h 30m 3 Exercises

Hands-on exercises to migrate InventoryStore product storage to HashMap, implement the CategoryRegistry with computeIfAbsent grouping, and track active categories with HashSet.

Migrate Product Storage to HashMap Open InventoryStore.java. Add private Map<String, Product> productMap = new HashMap<>(). Update addProduct() to put to the map, removeProduct() to use productMap.remove(id), getProduct() to use productMap.get(id), and getAllProducts() to return new ArrayList<>(productMap.values()). ~15 min
Implement Category Registry Open CategoryRegistry.java. Add private Map<String, Category> categories = new HashMap<>(). Implement addCategory(Category c), getCategory(String name), getAllCategories(). Add getProductsGroupedByCategory(List<Product> products) returning Map<String, List<Product>> using computeIfAbsent. ~15 min
Track Active Categories with HashSet In InventoryStore.java, add private Set<String> activeCategories = new HashSet<>(). In addProduct(), add p.getCategory() to activeCategories. In removeProduct(), after removal check if any remaining product still has that category; if not, remove from activeCategories. Add getActiveCategories() returning an unmodifiable set. Display active categories in the main menu. ~15 min
07
AI Lesson
AI Lesson

Generics

45m

Learn why generics exist, writing generic classes and methods, bounded type parameters, wildcards (extends/super), PECS rule, type erasure, and common generic pitfalls.

08
Lab Exercise
Lab Exercise

Generics - Lab Exercises

1h 40m 3 Exercises

Hands-on exercises to build a generic Repository class, add bounded generic methods (findMax with Comparable), and migrate InventoryStore to delegate to ProductRepository.

Build the Generic Repository Open ProductRepository.java. Add the type parameter <T> to the class declaration. Add private Map<String, T> store = new HashMap<>(). Implement save(String id, T item), findById(String id), findAll(), delete(String id), and count(). ~15 min
Add Bounded Generic Methods ~20 min
Migrate InventoryStore to Use the Repository ~20 min
09
AI Lesson
AI Lesson

Sorting and Comparable

1h 0m

Learn how Java's Comparable and Comparator interfaces enable sorting of objects, and how to use Collections.sort, Arrays.sort, and the Stream API's sorted() method.

10
Lab Exercise
Lab Exercise

Sorting - Lab Exercises

1h 40m 3 Exercises

Practice implementing Comparable on Product, creating Comparator instances, and sorting the inventory by multiple fields.

Implement Comparable on Product ~15 min
Sort by Price and Quantity with Comparator ~20 min
Multi-Field Sort: Category then Price ~20 min
11
AI Lesson
AI Lesson

Streams and Functional Interfaces

1h 0m

Learn the Java Stream API: filter, map, reduce, collect, and the core functional interfaces Predicate, Function, Consumer, and Supplier.

12
Lab Exercise
Lab Exercise

Streams - Lab Exercises

1h 40m 3 Exercises

Practice using the Java Stream API to filter, transform, and aggregate inventory data using Predicate, Function, and Collectors.

Filter and Collect Low-Stock Products ~15 min
Map Products to Labels and Calculate Total Value ~20 min
Group Products by Category with Collectors ~20 min
13
AI Lesson
AI Lesson

Capstone Briefing

1h 0m

A comprehensive review of all course concepts and a detailed briefing on the Capstone Project: building a complete Inventory Management System with categories, sorting, stream-based reporting, and generic repositories.

14
Lab Exercise
Lab Exercise

Capstone Project

2h 5m 3 Exercises

Build the complete Inventory Management System by implementing CategoryManager, ReorderQueue, InventoryReport, and InventoryManager using all course concepts: generics, collections, sorting, and streams.

Implement CategoryManager and ReorderQueue ~30 min
Implement InventoryReport Stream Methods ~25 min
Wire InventoryManager: Search and Sort ~25 min

This course includes:

  • 24/7 AI Instructor Support
  • Live Lab Environments
  • 7 Hands-on Lessons
  • 6 Months Access
  • Completion Badge
  • Certificate of Completion
Java Data Structures and OOP Badge

Earn Your Badge

Complete all lessons to unlock the Java Data Structures and OOP achievement badge.

Category
Skill Level Beginner
Total Duration 17h 35m
Java Data Structures and OOP Badge
Achievement Badge

Java Data Structures and OOP

Awarded for completing the Java Data Structures and OOP course, demonstrating proficiency in Java collections, generics, inheritance, polymorphism, and interfaces.

Course Java Data Structures and Collections
Criteria Complete all lessons and pass assessments in the Java Data Structures and OOP course.
Valid For 730 days

Skills You'll Earn

Collections Framework Generics Inheritance Polymorphism Interfaces Data Structures

Complete all lessons in this course to earn this badge