Java Tutorials_Generics(java泛型)

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是非常棘手的问题,他们不总立即是出现在表面,当它们运行的时候可能,在程序的运行的时候的出现的那一点问题早已偏离了实际问题的原因

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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值