Java Generics 简明教程

Java Generics Tutorial

Java 泛型方法和泛型类使程序员能够使用单个方法声明指定一组相关方法,或使用单个类声明指定一组相关类型。泛型还提供编译时类型安全性,允许程序员在编译时捕获无效类型。本参考将引导您使用 Java 泛型采用简单实用的方法。

Java Generic methods and generic classes enable programmers to specify, with a single method declaration, a set of related methods, or with a single class declaration, a set of related types, respectively. Generics also provide compile-time type safety that allows programmers to catch invalid types at compile time. This reference will take you through simple and practical methods using Java Generics.

Audience

此参考已为初学者准备,以帮助他们理解与 Java 泛型中的功能相关的基本功能。

This reference has been prepared for the beginners to help them understand the basic functionality related to functionality available in Java Generics.

Prerequisites

在开始使用此参考中给出的各种类型的示例进行练习之前,我假设您已经了解基本的 Java 编程。

Before you start doing practice with various types of examples given in this reference, I’m making an assumption that you are already aware of basic Java Programming.