
Explore naming conventions for generics by using a single uppercase letter for type parameters, with examples like E for element, V for value, and C for generic data.
Learn about lower bound wildcards in Java generics, using super to accept a type or its supertypes, and why extends restricts to subtypes in method parameters.
Declare a generic constructor with type parameter T on a store class to control what can be passed when creating objects. The lecture shows constraining inputs to enforce valid types.
Explore how a generic superclass can be extended by a subclass, with explicit type arguments, and how the generic type flows from store to box using integers or strings.
This lecture explains that interfaces cannot be instantiated, so collection classes implement them; some are abstract, others implement features, with list implementations and generics using reference types rather than primitives.
This lecture demonstrates using ArrayList.set to update a value at a specific index, and using addAll to merge another list and removeAll to delete elements.
Use the Arrays class to initialize lists in one step, and recognize that such lists are immutable and reject additions; create mutable lists by passing elements into a constructor.
Learn how HashSet capacity and load factor govern automatic resizing, starting from a default capacity of 16, with a 0.75 load factor that triggers doubling as elements fill up.
TreeSet keeps elements in ascending order as you insert them, offering automatic arrangement, unlike hash sets. When dealing with objects, use a comparator to define ordering in Java.
Use a comparator to compare cars by price and store them in a tree set, implementing with an anonymous class or a lambda and overriding toString for readable output.
Explore how a linked list implements a first in, first out queue with add and offer, and how to peek, poll, remove, and remove(element), plus iterating with a for-each loop.
Explore how a hash map implements the map interface by using put to store integer keys and values, and get to retrieve them, with unique keys and possibly shared values.
Understand how hash maps handle keys and values, and compare put versus putIfAbsent: put replaces an existing value, while putIfAbsent inserts only when the key is absent.
Learn how to access hash map values with values(), retrieve keys with keySet(), and remove entries using remove(key), which returns the removed value.
Apply hashmaps replaceAll to replace each value by a function of the key and value, using a lambda to generate new values such as value plus ten.
Explore how hash maps merge values with the merge method: if a key exists, apply a remapping function to old and new values; if not, insert the new value.
Learn HashMap extra methods for practical checks: use containsKey and containsValue to verify entries, check size and isEmpty, and clear the map to remove all elements.
Differentiate between optional of wrapper classes and optional of primitive; stream's average returns an OptionalDouble, a primitive double, not a wrapper.
Explore how to use optional on nullable returns, convert a possibly null person to an optional, and employ ifPresent to avoid null pointer exceptions, with implications for the Streams API.
Create streams from primitive values in Java using IntStream, DoubleStream, and LongStream, including range generation. See how primitive streams avoid boxing and support filtering and printing.
Demonstrates how min and max operate directly on primitive int streams, unlike streams of Integer objects that require a comparator and optional handling for results.
Learn how to use collectors to map a stream of objects into a map by choosing a key field, such as name or id, and a corresponding value field.
Explore generics and the collections framework, learn two ways to create generic classes, and use the streams API to perform operations on collections and stay current with Java's features.
Learn about Java Generics and how to create Generic classes. You also learn about Generic Interfaces and Methods.
After learning and understanding Java Generics we then dive into the Java Collections Framework where we learn about data structures such as List, ArrayList, HashMap, HashSet, LinkedList... and so on. Generics are an important part of the Java programming language.
We have extra lessons on Java Optional which helps us avoid null pointer exceptions in Java. You will learn about Optionals because it's knowledge will be applied when you learn about Java Streams API.
Finally, we learn about the Streams API, how it works and the various methods such as filter(), map(), flatMap(), reduce(), collect() ... and so on.
After this course, you should have a solid understanding of the Java Generics, the Collection Framework with its Data Structures and the Java Streams API.
In a nutshell, generics enable types (classes and interfaces) to be parameters when defining classes, interfaces and methods. Much like the more familiar formal parameters used in method declarations, type parameters provide a way for you to re-use the same code with different inputs. The difference is that the inputs to formal parameters are values, while the inputs to type parameters are types. (Java Docs)