- 定价:¥79.00
- 校园优惠价:¥49.77 (63折) (马上了解)
- 评分:
(已有172条评价)
- 促销活动:
- 我要买:
基本信息
- 原书名:Thinking in Java
- 原出版社: Prentice Hall PTR

编辑推荐
本书中文版:<a href="http://www.china-pub.com/computers/common/info.asp?id=34838" target="_blank">《Java编程思想(中文版.第4版)》</a>
最好的Java书籍……绝对令人震惊
Java书籍的最明智选择
最棒的编程书籍
内容简介
计算机书籍
《Java编程思想》(英文版·第4版)特色:·适合初学者与专业人员的经典的面向对象的叙述方式;为更新的Java SE5/6的相关内容增加了新的示例和章节。·测验框架显示程序输出。·设计模式贯穿于众多示例中:适配器、桥接器、职责链、命令、装饰器、外观、工厂方法、享元、点名、数据传输对象、空对象、代理、单例、状态、策略、模板方法以及访问者。·为数据传输引入了XML;为用户界面引入了SWT和Flash。·重新撰写了有关并发的章节,使您能牢牢地掌握线程的相关知识。·专门为第4版以及Java SE5/6重写了在700多个编译文件中的500多个程序。·支持网站包含了所有源代码、带注解的解决方案指南、网络日志以及多媒体学习资料。·完全覆盖了所有基础知识,同时也论述了高级特性。·详细彻底地阐述了面向对象原理。·在线可获得Java讲座CD,包含Bruce Eckel的全部多媒体讲座。
作译者
目录
Introduction
Introduction
Everything Is and Object
Operators
Controlling Execution
Initialization&Cleanup
Access Control
Reusing Classes
Polymorphism
Interfaces
Inner Classes
Holding Your Objects
Error Handling With Exceptions
Strings
Type Information
Generics
Arrays
Containers in Depoth
I/O
前言
Programming is about managing complexity: the complexity of the problem you want to solve, laid upon the complexity of the machine in which it is solved. Because of this complexity, most of our programming projects fail. And yet, of all the programming languages of which I am aware, almost none have gone all out and decided that their main design goal would be to conquer the complexity of developing and maintaining programs. Of course, many language design decisions were made with complexity in mind, but at some point there were always other issues that were considered essential to be added into the mix. Inevitably, those other issues are what cause programmers to eventually "hit the wall" with that language. For example, C++ had to be backwards-compatible with C (to allow easy migration for C programmers), as well as efficient. Those are both very useful goals and account for much of the success of C++, but they also expose extra complexity that prevents some projects from being finished (certainly, you can blame programmers and management, but if a language can help by catching your mistakes, why shouldn't it?). As another example, Visual BASIC (VB) was tied to BASIC, which wasn't really designed to be an extensible language, so all the extensions piled upon VI3 have produced some truly unmaintainable syntax. Peri is backwards-compatible with awk, sed, grep, and other Unix tools it was meant to replace, and as a result it is often accused of producing "write-only code" (that is, after a while you can't read it). On the other hand, C++, VB, Peri, and other languages like Smalltalk had some of their design efforts focused on the issue of complexity and as a result are remarkably successful in solving certain types of problems.
What has impressed me most as I have come to understand Java is that somewhere in the mix of Sun's design objectives, it seems that there was a goal of reducing complexity for the programmer. As if to say, "We care about reducing the time and difficulty of producing robust code." In the early days, this goal resulted in code that didn't run very fast (although this has improved over time), but it has indeed produced amazing reductions in development time-half or less of the time that it takes to create an equivalent C++ program. This result alone can save incredible amounts of time and money, but Java doesn't stop there. It goes on to wrap many of the complex tasks that have become important, such as multithreading and network programming, in language features or libraries that can at times make those tasks easy. And finally, it tackles some really big complexity problems: crossplatform programs, dynamic code changes, and even security, each of which can fit on your complexity spectrum anywhere from "impediment" to "showstopper." So despite the performance problems that we've seen, the promise of Java is tremendous: It can make us significantly more productive programmers.
In all ways-creating the programs, working in teams, building user interfaces to communicate with the user, running the programs on different types of machines, and easily writing programs that communicate across the Intemet-Java increases the communication bandwidth between people.
I think that the results of the communication revolution may not be seen from the effects of moving large quantities of bits around. We shall see the true revolution because we will all communicate with each other more easily: one-on-one, but also in groups and as a planet. I've heard it suggested that the next revolution is the formation of a kind of global mind that results from enough people and enough interconnectedness. Java may or may not be the tool that foments that revolution, but at least the PoSsibility has made me feel like I'm doing something meaningful by attempting to teach the language.
Java SE5 and SE6
This edition of the book benefits greatly from the improvements made to the Java language in what Sun originally called JDK 1.5, and then later changed to JDK5 or J2SE5, then finally they dropped the outdated "2" and changed it to Java SEs. Many of the Java SE5 language changes were designed to improve the experience of the programmer. As you shall see, the Java language designers did not completely succeed at:this task, but in general they made large steps in the right direction.
One of the important goals of this edition is to completely absorb the improvements of Java SE5/6, and to introduce and use them throughout this book. This means that this edition takes the somewhat bold step of being "Java SE5/6-only,' and much of the code in the book will not compile with earlier versions of Java; the build system will complain and stop if you try. However, I think the benefits are worth the risk.
Ifyou are somehow fettered to earlier versions of Java, I have covered the bases by providing free downloads of previous editions of this book via www.MindView, net. For various reasons, I have decided not to provide the current edition of the book in free electronic form, but only the prior editions.
Java SE6
This book was a monumental, time-consuming project, and before it was published, Java SE6 (code-named mustang) appeared in beta form. Although there were a few minor changes in Java SE6 that improved some of the examples in the book, for the most part the focus of Java SE6 did not affect the content of this book; the features were primarily speed improvements and library features that were outside the purview of this text.
The code in this book was successfully tested with a release candidate of Java 8E6, so I do not expect any changes that will affect the content of this book. If there are any important changes by the time Java SE6 is officially released, these will be reflected in the book's source code, which is downloadable from www.MindView.net.
The cover indicates that this book is for "Java SE5/6," which means "written for Java SE5 and the very significant changes that version introduced into the language, but is equally applicable to Java SE6."
The 4th edition
The satisfaction of doing a new edition of a book is in getting things "right," according to what I have learned since the last edition came out. Often these insights are in the nature of the saying "A learning experience is what you get when you don't get what you want," and my opportunity is to fix something embarrassing or simply tedious. Just as often, creating the next edition produces fascinating new ideas, and the embarrassment is far outweighed by the delight of discovery and the ability to express ideas in a better form than what I have previously achieved.
There is also the challenge that whispers in the back of my brain, that of making the book something that owners of previous editions will want to buy. This presses me to improve, rewrite arid reorganize everything that I can, to make the book a new and valuable experience for dedicated readers.
Changes
The CD-ROM that has traditionally been packaged as part of this book is not part of this edition. The essential part of that CD, the Thinking in C multimedia seminar (created for MindView by Chuck Allison), is now available as a downloadable Flash presentation. The goal of that seminar is to prepare those who are not familiar enough with C syntax to understand the material presented in this book. Although two of the chapters in this book give decent introductory syntax coverage, they may not be enough for people without an adequate background, and Thinking in C is intended to help those people get to the necessary level.
The Concurrency chapter (formerly called "Multithreading") has been completely rewritten to match the major changes in the Java SE5 concurrency libraries, but it still gives you a basic foundation in the core ideas of concurrency. Without that core, it's hard to understand more complex issues of threading. I spent many months working on this, immersed in that netherworld called "concurrency," and in the end the chapter is something that not only provides a basic foundation but also ventures into more advanced territory.
There is a new chapter on every significant new Java SE5 language feature, and the other new features have been woven into modifications made to the existing material. Because of my continuing study of design patterns, more patterns have been introduced throughout the book as well.
序言
但随着时间流逝,以及对Java的深入研究,我渐渐发现,与我所见过的其他编程语言相比,Java有着完全不同的核心目的。
程序设计其实是对复杂性的管理:待解决问题的复杂性,以及用来解决该问题的工具的复杂性。正是这种复杂性,导致多数程序设计项目失败。在我所知的所有程序设计语言中,几乎没有哪个将自己的设计目标专注于克服开发与维护程序的复杂性。当然,有些编程语言在设计决策时也曾考虑到复杂性的问题,然而,总是会有其他议题被认为更有必要加入到该语言中。于是不可避免地,正是这些所谓更必要的议题导致程序员最终“头撞南墙”。例如,C++选择向后兼容C(以便更容易吸引C程序员),以及具备C一样的高效率。这两点都是非常有益的设计目标,也确实促成了C++的成功,然而它们却暴露出更多的复杂性问题,而这也使得很多项目不得善终(你自然可以责怪程序员或者项目管理,但是,如果一种语言能够帮助你解决错误,那何乐而不为呢?)。再看一个例子,Visual Basic(VB)选择与Basic绑在一起,而Basic并未被设计为具备可扩展性的程序设计语言,结果呢,建立在VB之上的所有扩展都导致了无法维护的语法。还有Perl,它向后兼容awk、sed、grep,以及所有它打算替代的Unix工具,结果呢,人们开始指责Perl程序成了“不可阅读(write-only)的代码”(即,只要稍过一会儿,你就读不懂刚完成的程序了)。从另一个角度看,在设计C++,VB,Perl,以及Smalltalk之类的程序设计语言时,设计师也都为解决复杂性问题做了某种程度的工作。并且,正是解决某类特定问题的能力,成就了它们的成功。
随着对Java的了解越来越深,Sun对Java的设计目标给我留下了最深刻印象,那就是:为程序员减少复杂性。用他们的话说就是:“我们关心的是,减少开发健壮代码所需的时间以及困难。”在早期,这个目标使得代码的运行并不快(Java程序的运行效率已经改善了),但它确实显著地缩短了代码的开发时间。与用C++开发相同的程序相比,采用Java只需一半甚至更少的开发时间。仅此一项,就已经能节约无法估量的时间与金钱了。然而Java并未止步于此。它开始着手解决日渐变得重要的各种复杂任务,例如多线程与网络编程,并将其作为语言特性或以工具库的形式纳入Java,这使得开发此类应用变得倍加简单。最终,Java解决了一些相当大的复杂性问题:跨平台编程、动态代码修改,甚至是安全的议题。它让你在面对其中任何一个问题时,都能从“举步维艰”到“起立鼓掌”。抛去我们都能看到的性能问题,Java确实非常精彩地履行了它的诺言:极大地提升程序员的生产率。
同时,Java正从各个方面提升人们相互通讯的带宽。它使得一切都变得更容易:编写程序,团队合作,创建与用户交户的用户界面,在不同类型的机器上运行程序,以及编写通过因特网通信的程序。
我认为,通讯变革的成果并不见得就是传输巨量的比特。我们所看到的真正变革是人与人之间的通讯变得更容易了:无论是一对一的通信,还是群体与群体之间,甚至整个星球之间的通信。我曾听闻,在足够多的人之间的相互联系之上,下一次变革将是一种全球意识的形成。Java说不定就是促进该变革的工具,至少,它所具备的可能性使我觉得,教授这门语言是非常有意义的一件事情。
Java SE5 与 SE6
本书的第4版得益于Java语言的升级。Sun起初称其为JDK1.5,稍后改作JDK5或J2SE5,最终Sun弃用了过时的“2”,将其改为Java SE5。Java SE5的许多变化都是为了改善程序员的体验。你将会看到,Java语言的设计者们并未完全成功地完成该任务,不过,总的来说,他们已经向正确的方向迈出了一大步。
新版的一个重要目标就是完整地吸收Java SE5/6的改进,并通过本书介绍以及应用这些变化。这意味着本书基本可以称之为“只限Java SE5/6”。并且,书中的多数代码并没有经过老版本的Java编译测试,所以如果你使用的是老版本的Java,编译可能会报错并中止。不过,我觉得这样利大于弊。
如果你不得不采用老版本的Java,我仍然为你在www.MindView.net提供了本书早期版本的免费下载。基于某些原因,我决定不提供本书当前版本的免费电子版。
Java SE6
本书是一个非常耗时的,且具有里程碑意义的一个项目。就在本书出版之前,Java SE6(代号野马mustang)已经发布了beta版。虽然Java SE6中的一些小变化,对书中的代码示例有一点影响,但其主要的改进对本书的绝大部分内容并没有影响。因为Java SE6主要关注于提升速度,以及改进一些(不在本书讨论范围之内)类库的特性。
本书中代码全部用Java SE6的一个发布候选版(RC)进行过测试,因此我不认为Java SE6正式发布时会有什么变化能够影响本书的内容。如果到时真的有什么重要的改变,我将更新本书中的代码,你可以通过www.MindView.net下载。
本书的封面已经指出,本书面向“Java SE5/6”。也就是说本书的撰写“面向Java SE5及其为Java语言引入的重大变化,同时也适用于Java SE6”。
第4版
为一本书写作新版时,作者最满意的是:把事情做得“恰如其分”。这是我从本书上一个版本发布以来所学到的东西。通常而言,这种见识正如谚语所云,“学习就是从失败中汲取教训。”并且,我也借机进行了一些修订。与往常一样,一个新的版本必将带来引人入胜的新思想。此时,新发现带来的喜悦,采用比以往更好的形式表达思想的能力,已经远远超过了可能引入的小错误。
这也是对不断在我脑中盘旋低语着的一种挑战,那就是让持有本书老版本的读者也愿意购买新的版本。这些促使着我尽可能改进,重写,以及重新组织内容,为热忱的读者们献上一本全新的,值得拥有的书。
改变
此版本中将不再包含以往本书中所携带的CD光盘。该CD中的重要部分《Thinking in C》的多媒体教程(由Chuck Allison为MindView创建),现在提供了可下载的Flash版本。该教程是为不熟悉C语法的读者所准备的。虽然,本书用了两章对语法做了较为完整的介绍,然而对于没有相应背景知识的读者而言,这也许仍然不够。而《Thinking in C》正是为了帮助这些读者提升到必要的程度。
完全重写了“并发”这一章(以前称为“多线程”),以符合Java SE5并发类库的重大改变。它将为读者了解并发的核心思想打下基础。如果没有这些核心的基础知识,读者很难理解关于线程的更复杂的议题。我花了很多个月撰写这一章,深陷“并发”的地狱之中,最终,这一章不仅涵盖了基础知识,而且大胆地引入了一些高级议题。
媒体评论
这也是对不断在我脑中盘旋低语着的一种挑战,那就是让持有本书老版本的读者也愿意购买新的版本。这些促使着我尽可能改进,重写,以及重新组织内容,为热忱的读者们献上一本全新的,值得拥有的书。
改变
此版本中将不再包含以往本书中所携带的CD光盘。该CD中的重要部分《Thinking in C》的多媒体教程(由Chuck Allison为MindView创建),现在提供了可下载的Flash版本。该教程是为不熟悉C语法的读者所准备的。虽然,本书用了两章对语法做了较为完整的介绍,然而对于没有相应背景知识的读者而言,这也许仍然不够。而《Thinking in C》正是为了帮助这些读者提升到必要的程度。
完全重写了“并发”这一章(以前称为“多线程”),以符合Java SE5并发类库的重大改变。它将为读者了解并发的核心思想打下基础。如果没有这些核心的基础知识,读者很难理解关于线程的更复杂的议题。我花了很多个月撰写这一章,深陷“并发”的地狱之中,最终,这一章不仅涵盖了基础知识,而且大胆地引入了一些高级议题。
而对于Java SE5所具有的每一个重大的新特性,本书都有一个新的章节与之对应。其他的新特性则加入到了原有的章节中。我还一直在研究设计模式,因此在本书中,也介绍了设计模式的相关内容。
本书经历了重大的重组。这大多源自教授Java的过程,以及我对于“章节”的意义的重新思考。以前,我会不假思索地认为,每个“章节”应该包含一个“足够大的”主题。但是,在我教授设计模式的时候,我发现,如果每次只介绍一个模式(即使讲课的时间很短),然后立刻组织大家做练习,此时那些学员们的表现是最好的(我发现,这种节奏对于我这个老师而言也更有乐趣)。因此,在这一版中,我试着打破按主题划分章节的做法,也不理会章节的长度。我想,这也是一个改进。
我同样也认识到代码测试的重要性。必须要有一个内建的测试框架,并且每次你开发系统时都必须进行测试。否则,根本没有办法知道代码可靠与否。为了做到这一点,我开发了一个测试框架以显示和验证本书中每一个程序的输出结果。(该框架是用Python编写的,你可以在www.MindView.net找到可下载的代码。)关于测试的话题在附录中有讨论,你可以在http://MindView.net/Books/BetterJava找到。其中还包含了其他一些基本技术,我认为所有程序员都应该将它们加入到自己的工具箱中。
此外,我还仔细检查了书中的每一个示例,并且问我自己,“我为什么采用这种方式实现?”对大多数的示例,我都做了一定程度的修订与改进,使得这些示例更加贴切。同时,也传达出我所认为的Java编程中的最佳实践(至少起到抛砖引玉的作用)。许多以前的示例都经过了重新设计与重新编写;同时,删除了不再有意义的示例,也添加了新的示例。
读者们为此书的前三个版本提出了许多许多精彩的意见。这自然使我觉得非常高兴。不过,偶尔读者也会有抱怨,例如有读者埋怨“本书太长了”。对我而言,如果“页数太多”是你唯一的苦恼,那这真令人哭笑不得。(据说奥地利皇帝曾抱怨莫扎特的音乐“音符太多”!我可不是想把自己比作莫扎特。)此外,我只能猜测,发出这种抱怨的读者还不了解Java语言的博大精深,而且也没有看过这一领域的其他书籍。无论如何,在这一版中,我已经删减了过时无用,或不再重要内容。总的来说,我已经尽我所能仔细复查了全书,进行了必要的增删与改进。对于删除旧的章节,我还是挺放心的。因为原始的材料在网站上都有)。本书从第一版到第三版,以及本书的附录,都可以从此网站上下载。
对于仍然不能接受本书篇幅的读者,我向你们道歉。请相信,我已经尽我所能精简本书的长度了。
书摘
这也是对不断在我脑中盘旋低语着的一种挑战,那就是让持有本书老版本的读者也愿意购买新的版本。这些促使着我尽可能改进,重写,以及重新组织内容,为热忱的读者们献上一本全新的,值得拥有的书。
改变
此版本中将不再包含以往本书中所携带的CD光盘。该CD中的重要部分《Thinking in C》的多媒体教程(由Chuck Allison为MindView创建),现在提供了可下载的Flash版本。该教程是为不熟悉C语法的读者所准备的。虽然,本书用了两章对语法做了较为完整的介绍,然而对于没有相应背景知识的读者而言,这也许仍然不够。而《Thinking in C》正是为了帮助这些读者提升到必要的程度。
完全重写了“并发”这一章(以前称为“多线程”),以符合Java SE5并发类库的重大改变。它将为读者了解并发的核心思想打下基础。如果没有这些核心的基础知识,读者很难理解关于线程的更复杂的议题。我花了很多个月撰写这一章,深陷“并发”的地狱之中,最终,这一章不仅涵盖了基础知识,而且大胆地引入了一些高级议题。
而对于Java SE5所具有的每一个重大的新特性,本书都有一个新的章节与之对应。其他的新特性则加入到了原有的章节中。我还一直在研究设计模式,因此在本书中,也介绍了设计模式的相关内容。
本书经历了重大的重组。这大多源自教授Java的过程,以及我对于“章节”的意义的重新思考。以前,我会不假思索地认为,每个“章节”应该包含一个“足够大的”主题。但是,在我教授设计模式的时候,我发现,如果每次只介绍一个模式(即使讲课的时间很短),然后立刻组织大家做练习,此时那些学员们的表现是最好的(我发现,这种节奏对于我这个老师而言也更有乐趣)。因此,在这一版中,我试着打破按主题划分章节的做法,也不理会章节的长度。我想,这也是一个改进。
我同样也认识到代码测试的重要性。必须要有一个内建的测试框架,并且每次你开发系统时都必须进行测试。否则,根本没有办法知道代码可靠与否。为了做到这一点,我开发了一个测试框架以显示和验证本书中每一个程序的输出结果。(该框架是用Python编写的,你可以在www.MindView.net找到可下载的代码。)关于测试的话题在附录中有讨论,你可以在http://MindView.net/Books/BetterJava找到。其中还包含了其他一些基本技术,我认为所有程序员都应该将它们加入到自己的工具箱中。
此外,我还仔细检查了书中的每一个示例,并且问我自己,“我为什么采用这种方式实现?”对大多数的示例,我都做了一定程度的修订与改进,使得这些示例更加贴切。同时,也传达出我所认为的Java编程中的最佳实践(至少起到抛砖引玉的作用)。许多以前的示例都经过了重新设计与重新编写;同时,删除了不再有意义的示例,也添加了新的示例。
读者们为此书的前三个版本提出了许多许多精彩的意见。这自然使我觉得非常高兴。不过,偶尔读者也会有抱怨,例如有读者埋怨“本书太长了”。对我而言,如果“页数太多”是你唯一的苦恼,那这真令人哭笑不得。(据说奥地利皇帝曾抱怨莫扎特的音乐“音符太多”!我可不是想把自己比作莫扎特。)此外,我只能猜测,发出这种抱怨的读者还不了解Java语言的博大精深,而且也没有看过这一领域的其他书籍。无论如何,在这一版中,我已经删减了过时无用,或不再重要内容。总的来说,我已经尽我所能仔细复查了全书,进行了必要的增删与改进。对于删除旧的章节,我还是挺放心的。因为原始的材料在网站上都有(www.MindView.net)。本书从第一版到第三版,以及本书的附录,都可以从此网站上下载。
对于仍然不能接受本书篇幅的读者,我向你们道歉。请相信,我已经尽我所能精简本书的长度了。</div>