Java教程
  • Introduction
  • Getting Started
    • The Java Technology Phenomenon
      • About the Java Technology
      • What Can Java Technology Do?
      • How Will Java Technology Change My Life?
    • The Hello World Application
    • A Closer Look at the Hello World Application
  • Learning the Java Language
    • Object-Oriented Programming Concepts
      • What Is an Object?
      • What Is a Class?
      • What Is Inheritance?
      • What Is an Interface?
      • What Is a package?
    • Language Basics
      • Java Language Keywords
    • Annotations
      • Annotations Basics
      • Declaring an Annotation Type
      • Predefined Annotation Types
      • Repeating Annotations
      • Type Annotations and Pluggable Type Systems
    • Generics
      • Why Use Generics?
      • Generic Types
        • Raw Types
      • Generic Methods
      • Bounded Type Parameters
        • Generic Methods and Bounded Type Parameters
      • Generics, Inheritance, and Subtypes
      • Type Inference
      • Wildcards
        • Upper Bounded Wildcards
        • Unbounded Wildcards
        • Lower Bounded Wildcards
        • Wildcards and Subtyping
        • Wildcard Capture and Helper Methods
        • Guidelines for Wildcard Use
      • Type Erasure
        • Erasure of Generic Types
        • Erasure of Generic Methods
        • Effects of Type Erasure and Bridge Methods
        • Non-Reifiable Types
      • Restrictions on Generics
Powered by GitBook
On this page

Was this helpful?

  1. Learning the Java Language

Generics

PreviousType Annotations and Pluggable Type SystemsNextWhy Use Generics?

Last updated 5 years ago

Was this helpful?

在任何重要的软件项目中,出现bug是日常。认真的计划,编码和测试可以减少bug的出现,但是bug总是时不时的出现在你的代码中。尤其是伴随着功能的新增你的代码量和复杂度也随之增加bug也随之而来。

幸运的是有些bug是容易发现的。比如,编译时bug就能被很早发现,你可以使用编译器的报错信息来确定问题所在并立即修复它。但是运行时bug会造成更大的麻烦,它们不会立即显现出来,当它们发生时,代码的位置可能和实际问题的原因相去甚远。

Generics(泛型)通过在编译时让你的bug更容易被检测而使得你的代码更加稳定,通过本章的介绍,你可以继续看Gilad Bracha的

教程