(19) 附录B:对比C++和Java 对一个 C++程序员,他应该已经掌握了面向对象程序设计的基本概念,而且Java 语法对他来说无疑是非常眼 熟的。这一点是明显的,因为 Java 本身就是从 C++衍生而来。但是,C++和Java 之间的确存在一些显著的差 异。这些差异意味着Java 在 C++基础上作出的重大改进。一旦理解了这些差异,就能理解为什么说Java 是 一种杰出的语言。这一附录便是为这个目的设立的,它讲述了使Java 与 C++明显有别的一些重要特性。 (20) 附录C:Java 编程规则 本附录提供了大量建议,帮助大家进行低级程序设计和代码编写。 (21) 附录D:性能 通过这个附录的学习,大家可发现自己Java 程序中存在的瓶颈,并可有效地改善执行速度。 (22) 附录E:关于垃圾收集的一些话 这个附录讲述了用于实现垃圾收集的操作和方法。 (23) 附录F:推荐读物 列出我感觉特别有用的一系列 Java 参考书。 6。 练习 为巩固对新知识的掌握,我发现简单的练习特别有用。所以读者在每一章结束时都能找到一系列练习。 大多数练习都很简单,在合理的时间内可以完成。如将本书作为教材,可考虑在课堂内完成。老师要注意观 察,确定所有学生都已消化了讲授的内容。有些练习要难些,他们是为那些有兴趣深入的读者准备的。大多 数练习都可在较短时间内做完,有效地检测和加深您的知识。有些题目比较具有挑战性,但都不会太麻烦。 事实上,练习中碰到的问题在实际应用中也会经常碰到。 7。 多媒体 CDROM 本书配套提供了一片多媒体CD…ROM,可单独购买及使用。它与其他计算机书籍的普通配套CD 不同,那些 CD 通常仅包含了书中用到的源码(本书的源码可从BruceEckel。 免费下载)。本CD…ROM 是一个独立的 产品,包含了一周“Hads…OnJava”培训课程的全部内容。这是一个由Bruce Eckel 讲授的、长度在 15小时 以上的课程,含500 张以上的演示幻灯片。该课程建立在这本书的基础上,所以是非常理想的一个配套产 品。 CD…ROM 包含了本书的两个版本: (1) 本书一个可打印的版本,与下载版完全一致。 (2) 为方便读者在屏幕上阅读和索引,CD…ROM 提供了一个独特的超链接版本。这些超链接包括: ■230 个章、节和小标题链接 ■3600 个索引链接 CD…ROM 刻录了 600MB 以上的数据。我相信它已对所谓“物超所值”进行了崭新的定义。 CD…ROM 包含了本书打印版的所有东西,另外还有来自五天快速入门课程的全部材料。我相信它建立了一个新 的书刊品质评定标准。 若想单独购买此CD…ROM,只能从Web 站点BruceEckel。 处直接订购。 8。 源代码 本书所有源码都作为保留版权的免费软件提供,可以独立软件包的形式获得,亦可从 http://BruceEckel。 下载。为保证大家获得的是最新版本,我用这个正式站点发行代码以及本书电 子版。亦可在其他站点找到电子书和源码的镜像版(有些站点已在http://BruceEckel。 处列出)。 但无论如何,都应检查正式站点,确定镜像版确实是最新的版本。可在课堂和其他教育场所发布这些代码。 版权的主要目标是保证源码得到正确的引用,并防止在未经许可的情况下,在印刷材料中发布代码。通常, 12 …………………………………………………………Page 14…………………………………………………………… 只要源码获得了正确的引用,则在大多数媒体中使用本书的示例都没有什么问题。 在每个源码文件中,都能发现下述版本声明文字: ////////////////////////////////////////////////// // Copyright (c) Bruce Eckel; 1998 // Source code file from the book 〃Thinking in Java〃 // All rights reserved EXCEPT as allowed by the // following statements: You can freely use this file // for your own work (personal or mercial); // including modifications and distribution in // executable form only。 Permission is granted to use // this file in classroom situations; including its // use in presentation materials; as long as the book // 〃Thinking in Java〃 is cited as the source。 // Except in classroom situations; you cannot copy // and distribute this code; instead; the sole // distribution point is http://BruceEckel。 // (and official mirror sites) where it is // freely available。 You cannot remove this // copyright and notice。 You cannot distribute // modified versions of the source code in this // package。 You cannot use this file in printed // media without the express permission of the // author。 Bruce Eckel makes no representation about // the suitability of this software for any purpose。 // It is provided 〃as is〃 without express or implied // warranty of any kind; including any implied // warranty of merchantability; fitness for a // particular purpose or non…infringement。 The entire // risk as to the quality and performance of the // software is with you。 Bruce Eckel and the // publisher shall not be liable for any damages // suffered by you or any third party as a result of // using or distributing software。 In no event will // Bruce Eckel or the publisher be liable for any // lost revenue; profit; or data; or for direct; // indirect; special; consequential; incidental; or // punitive damages; however caused and regardless of // the theory of liability; arising out of the use of // or inability to use software; even if Bruce Eckel // and the publisher have been advised of the // possibility of such damages。 Should the software // prove defective; you assume the cost of all // necessary servicing; repair; or correction。 If you // think you"ve found an error; please email all // modified files with clearly mented changes to: // Bruce@EckelObjects。。 (Please use the same // address for non…code errors found in the book。) ///////////////////////////////////////////////// 可在自己的开发项目中使用代码,并可在课堂上引用(包括学习材料)。但要确定版权声明在每个源文件中 得到了保留。 13 …………………………………………………………Page 15…………………………………………………………… 9。 编码样式 在本书正文中,标识符(函数、变量和类名)以粗体印刷。大多数关键字也采用粗体——除了一些频繁用到 的关键字(若全部采用粗体,会使页面拥挤难看,比如那些“类”)。 对于本书的示例,我采用了一种特定的编码样式。该样式得到了大多数Java 开发环境的支持。该样式问世已 有几年的时间,最早起源于Bjarne Stroustrup 先生在《The C++ Programming Language》里采用的样式 (Addison…Wesley 1991 年出版,第 2 版)。由于代码样式目前是个敏感问题,极易招致数小时的激烈?