10.7. Generic Methods - Video Example¶
In this video example, we identify some segments of code that are nearly identical except for the fact that they operate on different datatypes, then we refactor the code into a datatype-independent method using generics.
- Here is the starter code for the video (Note: filename will need to be changed):
Follow along with Dr. Cotterell as he creates a generic method using the starter code above:
- Here is a copy of the final Code from the Video:
Final Code: Driver.java
10.7.1. Additional Reading with More Examples¶
Now that you’re familiar with some of the basic concepts related to generic methods in Java, you should read the official Oracle reading:
If you have any questions related to the Generic Methods reading provided by Oracle, then feel free to ask them on the course Piazza.