



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This document from the university of maryland, college park's department of computer science provides an overview of generic programming and generic classes in java. It explains how to define constructs that can be used with different types, the use of inheritance or type variables for implementation, and the concept of a generic class with one or more type variables. The document also covers valid and invalid types for generic classes and how to define and use them. Students will learn how to define their own generic classes and use type variables to define variable types, method arguments, and return types.
Typology: Study notes
1 / 5
This page cannot be seen from the preview
Don't miss anything!




Department of Computer ScienceUniversity of Maryland, College Park
Generic Programming Generic Classes
You can define your own generic classes^ Define a class and follow the class namewith the type variable(s) in angle brackets.^ Use the type variable to define the type ofvariables, type of method arguments, returntype of a method, or in object allocation You can use any name for the type variable butusually uppercase short names (E, K) are used. Example: see Queue.java in code distribution