码迷,mamicode.com
首页 > 编程语言 > 详细

Java Tutorials_Generics(java泛型)

时间:2015-05-06 17:53:05      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:java tutorials_gener

Lesson: Generics (Updated)

In any nontrivial software project, bugs are simply a fact of life. Careful planning, programming, and testing can help reduce their pervasiveness, but somehow, somewhere, they‘ll always find a way to creep into your code. This becomes especially apparent as new features are introduced and your code base grows in size and complexity.

Fortunately, some bugs are easier to detect than others. Compile-time bugs, for example, can be detected early on; you can use the compiler‘s error messages to figure out what the problem is and fix it, right then and there. Runtime bugs, however, can be much more problematic; they don‘t always surface immediately, and when they do, it may be at a point in the program that is far removed from the actual cause of the problem.

Generics add stability to your code by making more of your bugs detectable at compile time. After completing this lesson, you may want to follow up with the Generics tutorial by Gilad Bracha.

Java泛型

在任何琐碎的软件项目中,bugs是一个简单的生活事实。你小心的计划,编程,并且加以测试能够帮助你减少普通的错误,但是不管怎样,也不论在哪些地方,这些bugs总会寻找一个方式浸入进你的代码,当你新的功能特性被引入和你的代码在数量和复杂的增长的时候是尤其的明显。

幸运的是,有一些代码是更容易被检测到比起其他的代码,例如:编译时的bugs在早期就能够被检测到,你能够利用编译的错误信息去思考问题出现在哪儿,并且修复他们,然后,运行时的bugs是非常棘手的问题,他们不总立即是出现在表面,当它们运行的时候可能,在程序的运行的时候的出现的那一点问题早已偏离了实际问题的原因

泛型给你的代码添加的健壮性通过做更多编译时检查,在学习这节课之后,你可能相应会一探究竟探究泛型指南手册


Java Tutorials_Generics(java泛型)

标签:java tutorials_gener

原文地址:http://blog.csdn.net/hephec/article/details/45537163

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!