
Explore Java generics and the collections framework, covering bounded and wildcard types, practical examples, key collection classes, iteration, and operations with predefined and custom types, plus a project.
This lecture introduces generics in Java, showing how a single parameterized class can print integers or strings without new classes, by carrying type information to handle different data types.
Learn how to use generics in Java by parametrizing classes with type information, using formal type parameters, and supplying actual types like integer or string to create type-safe, reusable code.
Learn the basics of java collections, including dynamic data structures, the list interface, and concrete classes like ArrayList. Compare non-generic and generic versions and explore add and get methods.
discover the two main benefits of generics in Java collections: type safety and eliminating type casting, demonstrated with generic lists of integers versus non-generic lists and compile-time errors.
Explore generics with user-defined classes to enforce type safety, contrasting raw and generic lists through student and teacher objects, and demonstrating compile-time errors for mismatched types in program 1.
See how generics eliminate the need for typecasting and reduce compile-time and runtime errors when accessing data in lists, using student and teacher examples to illustrate safer, type-specific access.
Explore bounded types in java generics by restricting type parameters to numeric types using extends Number, ensuring arithmetic operations stay valid with Integer, Long, Float, and Double.
Implement a generic class that sums numbers from numeric inputs and prints the total as a double, while enforcing bounded generics by extending Number to prevent string usage.
Explore bounded types in generics by using a class or interfaces as bounds, showing type parameters must extend a class or implement interfaces, and that multiple interfaces can be implemented.
Explore the Java collections framework hierarchy, focusing on List, Set, and Map interfaces and their insertion order rules. Learn how LinkedHashSet and LinkedHashMap preserve insertion order in common implementations.
Learn how to iterate an ArrayList of strings using for-each, an iterator, and a basic for loop, with examples like red, blue, green, and yellow.
Explore ArrayList operations with two color lists, applying addAll, removeAll, retainAll, clear, and contains to add, remove, and preserve matching elements.
Explore using ArrayList with custom objects and learn why equals and hashCode matter for content comparison, not references. Also learn how to override them with a unique rule number.
Learn how ArrayList supports contains and containsAll, use equals to enable proper containment checks in a student class, and compare two lists to find common elements.
Learn how hash set implements the set interface, prevents duplicates by the add result, and why insertion order is not guaranteed, due to the hash table and equals and hashCode.
Explore HashSet operations in Java by demonstrating add, removeAll, retainAll, contains, and containsAll, and learn why overriding hashCode and equals with the same fields (like roll number) prevents duplicate removal.
LinkedHashSet preserves insertion order, unlike HashSet, which uses a hash table and linked list and does not guarantee order. Both avoid duplicates, letting you compare their behavior with sample code.
Explore how hash map implements the map interface to store key–value pairs with unique keys and no insertion order, using a hash table. See how put inserts and returns values.
Learn to iterate a hash map in Java with for-each, iterator, and lambda, printing keys and values from entries, keySet, and values.
Demonstrate hash map basics by creating two maps, merging with putAll, observing key overwrite for duplicates, containsKey and containsValue checks, and that insertion order isn't preserved.
Compare linked hash map with hash map, noting linked hash map preserves insertion order and allows duplicate values but not duplicate keys, using the same methods and for-each display.
TreeSet stores unique elements in ascending order using natural ordering. For custom types, implement Comparable or provide a Comparator; integers and strings sort automatically.
Explore tree map, a sorted map backed by a red-black tree. Keys sort by natural order; insertion order is not preserved, and values may duplicate.
Learn how to provide sorting logic for Java collections by implementing the comparable interface or supplying a comparator externally, then sort with collections.sort to achieve natural or custom ordering.
Learn to use the comparator interface to define sorting when you cannot modify the source class. Implement comparators for ascending or descending order and apply them to maps and sets.
Practice the programs from tutorials, modify the code, and implement collections and generics in your projects to solve real-world problems.
This course is for anyone who wants to understand the concept of Generics in Java and how to use them along with Java Collections Framework. Java Collections and Generics is one of the most important topics in Java programming language. In industry projects, there is a heavy use of Collections and Generics. It is really essential to get hands-on experience on different Java collections. This course will teach you how generics are used, the benefits of using them, how generics provide us type-safety etc. It will also make you familiar with some of the most commonly used collections. This course is highly practical-base and main focus is on practicals rather than the theory.
Some of the highlights of this course:-
As it’s a short course, it won’t be boring at all. You need to invest only around 2-3 hours of your time. I believe you will enjoy this course and learn a lot. Happy Coding :)