Learn about using generics in Java. Discover how to describe generics in Java and create your own generic classes, interfaces, and methods.
- [Peggy] Welcome! My name is Peggy Fisher and I'm going to be your instructor for this course. I'm thrilled that you decided to learn more about using generics in Java. In this course, I will provide a definition of generics in Java, then discuss the syntax associated with using this approach. Next, we will review generics as it pertains to classes, interfaces, methods, and even talk about bounded types. Generics were added to the Java programming language with Java version 5.0.
According to the Java website, for enhancements included in JDK 5.0, it says, "This long awaited enhancement to the type system "allows a type or method to operate on objects "of various types while providing compile time type safety. "It adds compile time type safety "to the collections framework and eliminates "the drudgery of casting." In a nutshell, that's what generics do for us. At the end of the course, you should be able to describe generics in Java, identify existing types of generic classes, interfaces, and methods, as well as create your own.
- Cite syntax examples for a generic method.
- Describe generic interfaces.
- Identify a generic method that limits its generic type to characters.
- Identify syntax examples.