2.4. Generics Intro¶
2.4.1. Objectives¶
Declare variables and instantiate objects that are generic types and take a type parameter
Trace code that demonstrates the use of both generics and inheritance
Design and write a generic class
Write and use generic methods
Assess the software engineering benefits of using generic methods
Assess the benefits and possible tradeoffs of using generic types vs Object type
2.4.1.1. Suggested Reading¶
Java Interlude 1 Generics from Data Structures and Abstractions with Java by Frank M. Carrano and Timothy Henry
2.4.2. Interactive: Generics Intro Video¶
Follow Along, Practice and Explore
ArrayBasics.java
- Download to run and explore the java file (see below) from the video on your own in eclipse. You may download the standalone *.java file for this example. To run the standalone *.java file you will need to
create a new Eclipse project, then
create a package within the project called “example” (the package named at the top of the class MUST match the package the file is placed in within the Eclipse project), and finally
download and import the standalone *.java file(s) to the created package.