Skip to content

Latest commit

 

History

History
20 lines (13 loc) · 1.41 KB

File metadata and controls

20 lines (13 loc) · 1.41 KB

Unique Book Collection Manager

Course: Object-Oriented Programming in JAVA Lab (BCA39109) | Semester: BCA 3rd Sem

This project demonstrates how to use the Java Collections Framework to store unique objects. While a HashMap can be used as a workaround (by using a concatenated string as a key), this implementation uses a HashSet to fulfill the core Object-Oriented Programming requirement of defining object equality intrinsically.

🧠 Core OOP & Collections Concepts Demonstrated

  • HashSet: Utilizing java.util.HashSet to automatically filter out duplicate entries in a collection.
  • Object Equality (equals()): Overriding the default equals() method in the Book class so that Java compares the actual values (Title and Author) rather than the memory addresses of the objects.
  • Hash Codes (hashCode()): Overriding the hashCode() method to maintain the strict Java contract: if two objects are equal according to equals(), they must have the same hash code. This is how HashSet lightning-fast duplicate checking works under the hood!
  • Encapsulation: Keeping class fields private and exposing functionality through methods like display().

🚀 How to Compile and Run

To run this program, ensure you have the Java Development Kit (JDK) installed on your machine.

  1. Open your terminal or command prompt.
  2. Navigate to the directory containing the file.
  3. Compile the Java code: