Effective Java 47 Know and use the libraries
2014-04-10 07:25 小郝(Kaibo Hao) 阅读(317) 评论(0) 编辑 收藏 举报Advantages of use the libraries
-
By using a standard library, you take advantage of the knowledge of the experts who
wrote it and the experience of those who used it before you.
Use Random.nextInt(int) to get the random number without flaw.
- You don't have to waste your time writing ad hoc solutions to problems that are only marginally related to your work.
- Performance tends to improve over time, with no effort on your part.
- Libraries maintained by community also tend to gain new functionality over time.
-
Standard libraries is that you place your code in the mainstream. Such code is more easily readable, maintainable, and reusable by the multitude of developers.
Libraries you should know
Every programmer should be familiar with the contents of java.lang, java.util, and, to a lesser extent, java.io. Collections Framework under java.util, Java.util.concurrent.
Summary
Don't reinvent the wheel. If you need to do something that seems like it should be reasonably common, there may already be a class in the libraries that does what you want. If there is, use it; if you don't know, check. Economies of scale dictate that library code receives far more attention than most developers could afford to devote to the same functionality.
出处:http://www.cnblogs.com/haokaibo/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。