This project was developed for the SLIIT Object-Oriented Programming (OOP) module to demonstrate the use of Java Collections Framework and Generics.
It includes two mini applications: BookApp (PriorityQueue) and InventoryApp (HashMap).
This project showcases how to:
- Use PriorityQueue to manage book titles dynamically.
- Use HashMap to manage a product inventory with unique product codes.
- Apply Generics for type safety and clean object management.
Implements a library management system using a PriorityQueue.
- Accepts book titles until the user types
"done". - Allows removing a specific book by title.
- Displays whether removal was successful or not.
- Counts and prints remaining books in alphabetical order.
- PriorityQueue for sorted data storage.
Scannerfor input handling.- Generics for type-safe collection operations.
Implements a simple inventory system using a HashMap.
- Adds, updates, and removes products.
- Stores product details (code, name, quantity, price).
- Displays complete inventory after each operation.
- Automatically updates products if the code already exists.
- HashMap for key-value storage.
- Object references as map values.
- Method-based CRUD operations.
- Iteration using enhanced for-loops.
Helper class defining the product structure with:
- Product code (
String) - Product name (
String) - Quantity in stock (
int) - Price per unit (
double)
Used as the value object in the inventory HashMap.
Clone the Repository
git clone https://github.com/<your-username>/Java-Collections-Framework-Examples.git
cd Java-Collections-Framework-Examples
🧠 Concepts Demonstrated
| Concept | Description |
| ----------------- | ----------------------------------------- |
| **PriorityQueue** | For ordered book title management |
| **HashMap** | For efficient key-value product inventory |
| **Generics** | For compile-time type safety |
| **Encapsulation** | Through the Tool (Product) class |
| **Polymorphism** | Used via overridden `toString()` methods |