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.
Understand the need for generics - Java Tutorial
From the course: Java: Generic Classes
Understand the need for generics
- [Instructor] Let us understand the need for generics. But before that, we will have to know a couple of things well, the first one is recap of a few common terms that we use in the Java language. The first term is type. Type is any class, interface or enumerated datatype. And this type could be inbuilt, that is from the Java APIs, or it could be custom, that is developed by you. An example of an inbuilt type from the Java APIs is the class string, the class object, or even the interfaces, like list, set, map, et cetera. In your application, if you have a class called product, that is a type. If somewhere in your code you have an interface called Bounceable that you coded, that is also a type. The next term is object type reference. This means that you have a variable which is of the object type. Now object as we know is the super class of all the classes in Java. So if we write code like this, object name equal…
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.