# Generics

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

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

`Generics`（泛型）通过在编译时让你的bug更容易被检测而使得你的代码更加稳定，通过本章的介绍，你可以继续看`Gilad Bracha`的[教程](https://docs.oracle.com/javase/tutorial/extra/generics/index.html)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://eric3wade.gitbook.io/java/learning-the-java-language/generics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
