Documentation

The Java™ Tutorials
Hide TOC
Type Erasure类型擦除
Trail: Learning the Java Language
Lesson: Generics (Updated)

Type Erasure类型擦除

Generics were introduced to the Java language to provide tighter type checks at compile time and to support generic programming. Java语言中引入了泛型,以在编译时提供更严格的类型检查,并支持泛型编程。To implement generics, the Java compiler applies type erasure to:为了实现泛型,Java编译器将类型擦除应用于:

Type erasure ensures that no new classes are created for parameterized types; consequently, generics incur no runtime overhead.类型擦除确保没有为参数化类型创建新类;因此,泛型不会产生运行时开销。


Previous page: Guidelines for Wildcard Use
Next page: Erasure of Generic Types