From the course: Java: Generic Classes
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Generic class hierarchies - Java Tutorial
From the course: Java: Generic Classes
Generic class hierarchies
- [Instructor] Let us now understand generic class hierarchies but before that, let's do a quick recap of Java inheritance. When you implement inheritance with Java, you can always assign an object of the child class to a reference variable of the parent class. So let's say you have a class called Animal. This is the super class, and you're going to have a Dog, class which is derived out of Animal. So Dog is the sub-class. When you have this kind of a relationship, you can write a line of code like this, Animal animal = new Dog, which means you have an object of the dog, which is the sub-class, and you can refer to it by a variable of the type Animal, which is the superclass. Additionally, in inheritance with Java, you can always pass child class as an argument to a method that accepts the parent class as a parameter. Let's understand this. Let's say you have a class called AnimalUtils and inside that, you have a static…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Generic class hierarchies8m 59s
-
(Locked)
Type argument hierarchies5m 36s
-
(Locked)
Understand type erasure in generics6m 26s
-
(Locked)
Understand bridge methods3m 12s
-
(Locked)
Understand type inference and target types17m 5s
-
Applying wildcard arguments21m 22s
-
(Locked)
Restrictions on generics4m 8s
-
(Locked)
-