⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tij302.htm

📁 这也是我们java老师给我们的thinking in java的一些资料
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<p class="EmphasisP"><b><i>Chapter 9:	Error Handling with Exceptions</i></b><br></p>
<p>The basic philosophy of Java is that badly-formed code will not be run. As much as possible, the compiler catches problems, but sometimes a problem&#151;either a programmer error or a natural error condition that occurs as part of the normal execution of the program&#151;can be detected and dealt with only at run time. Java has <i>exception handling</i> to deal with any problems that arise while the program is running. This chapter examines how the keywords <b>try</b>, <b>catch</b>, <b>throw</b>, <b>throws</b>, and <b>finally</b> work in Java, when you should throw exceptions, and what to do when you catch them. In addition, you&#146;ll see Java&#146;s standard exceptions, how to create your own, what happens with exceptions in constructors, and how exception handlers are discovered during an exception. <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Intro_50" title="Send BackTalk Comment">Feedback</a></font><br></p>
<p class="EmphasisP"><b><i>Chapter 10:	Detecting Types</i></b><br></p>
<p>Java run-time type identification (RTTI) lets you find the exact type of an object when you have a reference to only the base type. Normally, you&#146;ll want to intentionally ignore the exact type and let Java&#146;s dynamic binding mechanism (polymorphism) implement the correct behavior for that type. But occasionally, it is very helpful to know the exact type of an object for which you have only a base reference. Often this information allows you to perform a special-case operation more efficiently. This chapter also introduces the Java <i>reflection</i> mechanism. You&#146;ll learn what RTTI and reflection are for and how to use them, and also how to get rid of RTTI when it doesn&#146;t belong there. <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Intro_52" title="Send BackTalk Comment">Feedback</a></font><br></p>
<p class="EmphasisP"><b><i>Chapter 11:	Collections of Objects </i></b><br></p>
<p>It&#146;s a fairly simple program that has only a fixed quantity of objects with known lifetimes. In general, your programs will always be creating new objects at a variety of times that will be known only while the program is running. In addition, you won&#146;t know until run time the quantity or even the exact type of the objects you need. To solve the general programming problem, you need to create any number of objects anywhere, at any time. This chapter explores in depth the collections library that Java supplies to hold objects while you&#146;re working with them: the simple arrays and more sophisticated containers (data structures) such as <b>ArrayList </b>and <b>HashMap</b>. <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Intro_49" title="Send BackTalk Comment">Feedback</a></font><br></p>
<p class="EmphasisP"><b><i>Chapter 12:	The Java I/O System </i></b><br></p>
<p>Theoretically, you can divide any program into three parts: input, process, and output. This implies that I/O (input/output) is an important part of the equation. In this chapter you&#146;ll learn about the different classes that Java provides for reading and writing files, blocks of memory, and the console. The evolution of the Java I/O framework and the JDK 1.4 &#147;new&#148; I/O (<b>nio</b>) will be examined. In addition, this chapter shows how you can take an object, &#147;stream&#148; it (so that it can be placed on disk or sent across a network), and then reconstruct it, which is handled for you with Java&#146;s <i>object serialization</i>. Java&#146;s compression libraries, which are used in the Java ARchive (JAR) file format, are examined. Finally, the new preferences application program interface (API) and regular expressions are explained. <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Intro_51" title="Send BackTalk Comment">Feedback</a></font><br></p>
<p class="EmphasisP"><b><i>Chapter 13:	Concurrency </i></b><br></p>
<p>Java provides a built-in facility to support multiple concurrent subtasks, called <i>threads</i>, running within a single program. (Unless you have multiple processors on your machine, this is only the <i>appearance</i> of multiple subtasks.) Although these can be used anywhere, threads are most apparent when trying to create a responsive user interface so, for example, a user isn&#146;t prevented from pressing a button or entering data while some processing is going on. This chapter gives you a solid grounding in the fundamentals of concurrent programming. <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Intro_54" title="Send BackTalk Comment">Feedback</a></font><br></p>
<p class="EmphasisP"><b><i>Chapter 14:	Creating Windows and Applets</i></b><br></p>
<p>Java comes with the Swing GUI library, which is a set of classes that handle windowing in a portable fashion. These windowed programs can either be World Wide Web applets or standalone applications. This chapter is an introduction to the creation of programs using Swing. Applet signing and <i>Java Web Start</i> are demonstrated. Also, the important <i>JavaBeans</i> technology is introduced, which is fundamental for the creation of Rapid Application Development (RAD) program-building tools. <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Intro_53" title="Send BackTalk Comment">Feedback</a></font><br></p>
<p class="EmphasisP"><b><i>Chapter 15:	Discovering Problems</i></b><br></p>
<p>Language-checking mechanisms can take us only so far in our quest to develop a correctly-working program. This chapter presents tools to solve the problems that the compiler doesn&#146;t. One of the biggest steps forward is the incorporation of <i>automated unit testing. </i>For this book, a custom testing system was developed to ensure the correctness of the program output, but the defacto standard <b>JUnit</b> testing system is also introduced. Automatic building is implemented with the open-source standard Ant tool, and for teamwork, the basics of CVS are explained. For problem reporting at run time, this chapter introduces the Java <i>assertion</i> mechanism (shown here used with <i>Design by Contract</i>), the logging API, debuggers, profilers, and even doclets (which can help discover problems in source code).<br></p>
<p class="EmphasisP"><b><i>Chapter 16:	Analysis &amp; Design</i></b><br></p>
<p>The object-oriented paradigm is a new and different way of thinking about programming, and many people have trouble at first knowing how to approach an OOP project. Once you understand the concept of an object, and as you learn to think more in an object-oriented style, you can begin to create &#147;good&#148; designs that take advantage of all the benefits that OOP has to offer. This chapter introduces the ideas of analysis, design, and some ways to approach the problems of developing good object-oriented programs in a reasonable amount of time. Topics include Unified Modeling Language (UML) diagrams and associated methodology, use cases, Class-Responsibility-Collaboration (CRC) cards, iterative development, <i>Extreme Programming</i> (XP), ways to develop and evolve reusable code, and strategies for transition to object-oriented programming.<br></p>
<p class="EmphasisP"><b><i>Appendix A:	Passing &amp; Returning Objects</i></b><br></p>
<p>Since the only way you talk to objects in Java is through references, the concepts of passing an object into a method and returning an object from a method have some interesting consequences. This appendix explains what you need to know to manage objects when you&#146;re moving in and out of methods, and also shows the <b>String</b> class, which uses a different approach to the problem. <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Intro_56" title="Send BackTalk Comment">Feedback</a></font><br></p>
<p class="EmphasisP"><b><i>Appendix B:	Java Programming Guidelines</i></b><br></p>
<p>This appendix contains suggestions that I have discovered and collected over the years to help guide you while performing low-level program design and writing code. <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Intro_58" title="Send BackTalk Comment">Feedback</a></font><br></p>
<p class="EmphasisP"><b><i>Appendix C:	Supplements</i></b><br></p>
<p>Descriptions of additional learning material available from MindView:<br>1. The CD ROM that&#146;s in the back of this book, which contains the <i>Foundations for Java </i>seminar-on-CD, to prepare you for this book.<br>2. The <i>Hands-On Java</i> CD ROM, 3<sup>rd</sup> Edition, available at <i>www.MindView.net</i>. A seminar-on-CD that&#146;s based on the material in this book.<br>3. The <i>Thinking in Java Seminar</i>. The MindView, Inc., main introductory seminar based on the material in this book. Schedule and registration pages can be found at <i>www.MindView.net</i>.<br>4. <i>Thinking in Enterprise Java</i>, a book that covers more advanced Java topics appropriate to enterprise programming. Available at <i>www.MindView.net</i>.<br>5. <i>The J2EE Seminar.</i> Introduces you to the practical development of real-world, Web-enabled, distributed applications with Java. See <i>www.MindView.net</i>.<br>6. Designing Objects &amp; Systems Seminar. Object-oriented analysis, design, and implementation techniques. See <i>www.MindView.net</i>.<br>7. <i>Thinking in Patterns (with Java)</i>, which covers more advanced Java topics on design patterns and problem-solving techniques. Available at <i>www.MindView.net</i>.<br>8. <i>Thinking in Patterns Seminar</i>. A live seminar based on the above book. Schedule and registration pages can be found at <i>www.MindView.net</i>.<br>9. <i>Design Consulting and Reviews.</i> Assistance to help keep your project in good shape.<br></p>
<p class="EmphasisP"><b><i>Appendix D:	Resources</i></b><br></p>
<p>A list of some of the Java books I&#146;ve found particularly useful. <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Intro_59" title="Send BackTalk Comment">Feedback</a></font><br></p>
<h2>
<a name="_Toc312373773"></a><a name="_Toc375545181"></a><a name="_Toc24775504"></a><a name="Heading862"></a>Exercises</h2>
<p>I&#146;ve discovered that simple exercises are exceptionally useful to complete a student&#146;s understanding during a seminar, so you&#146;ll find a set at the end of each chapter. <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Intro_60" title="Send BackTalk Comment">Feedback</a></font><br></p>
<p>Most exercises are designed to be easy enough that they can be finished in a reasonable amount of time in a classroom situation while the instructor observes, making sure that all the students are absorbing the material. Some are more challenging, but none present major challenges. (Presumably, you&#146;ll find those on your own&#151;or more likely, they&#146;ll find you). <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Intro_61" title="Send BackTalk Comment">Feedback</a></font><br></p>
<p>Solutions to selected exercises can be found in the electronic document <i>The Thinking in Java Annotated Solution Guide</i>, available for a small fee from <i>www.BruceEckel.com</i>. <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Intro_62" title="Send BackTalk Comment">Feedback</a></font><br></p>
<h2>
<a name="_Ref310733137"></a><a name="_Toc312373774"></a><a name="_Toc375545182"></a><a name="_Toc24775505"></a><a name="Heading866"></a>The
CD ROM</h2>
<p>Another bonus with this edition is the CD ROM that is packaged in the back of the book. I&#146;ve resisted putting CDs in the back of my books in the past because I felt the extra charge for a few kilobytes of source code on an enormous CD was not justified, preferring instead to allow people to download such things from my Web site. However, you&#146;ll soon see that this CD is different. <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Preface_18" title="Send BackTalk Comment">Feedback</a></font><br></p>
<p>The CD doesn&#146;t contain the source code from the book, but instead has a link to the code at <i>www.MindView.net</i> (you don&#146;t need the link on the CD to get to the source code. You can just go to the site and find it that way). There are two reasons for this: the code was not complete at the time the CD had to be sent to the printer, and this approach allows the code to evolve and be corrected as any issues arise. <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]A0545" title="Send BackTalk Comment">Feedback</a></font><br></p>
<p>Because the book has changed significantly over the three editions, the CD contains the first and second editions of the book in HTML format, including sections that for aforementioned reasons were removed from later editions but which may in some cases be useful to you. In addition, you can download the HTML version of the current (third edition) book from <i>www.MindView.net</i>, and this will include corrections as they are discovered and fixed. One benefit of the HTML version is that the index is hyperlinked so navigating it is much simpler. <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Preface_19" title="Send BackTalk Comment">Feedback</a></font><br></p>
<p>The bulk of the 400+ Megabytes of the CD, however, is a full multimedia course called<i> Foundations for Java</i>. This includes the <i>Thinking in C</i> seminar that gives you an introduction to the C syntax, operators, and functions that Java syntax is based upon<i>. </i>In addition, it includes the first seven lectures from the second edition of the <i>Hands-On Java</i> seminar-on-CD that I created and narrate. Although historically the entire <i>Hands-On Java</i> CD is only available for sale separately (this is also the case with the third edition of the <i>Hands-On Java</i> CD that may be available when you read this&#151;see <i>www.MindView.net</i>), I decided to include the first seven lectures from the second edition because they will not have changed too much in relationship to the third edition of the book, so it will not only provide you (along with <i>Thinking in C</i>)<i> </i>with a foundation for this book, but in addition I hope it will give you a taste for the quality and value of the <i>Hands-On Java CD</i>, 3<sup>rd</sup> Edition. <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]A0662" title="Send BackTalk Comment">Feedback</a></font><br></p>
<p>I originally commissioned Chuck Allison to create the <i>Thinking in C </i>part of this seminar-on-CD ROM as a standalone product, but decided to include it with the second editions of both <i>Thinking in C++</i> and <i>Thinking in Java</i> because of the consistent experience of having people come to seminars without an adequate background in basic C syntax. The thinking apparently goes &#147;I&#146;m a smart programmer and I don&#146;t want to learn C, but rather C++ or Java, so I&#146;ll just skip C and go directly to C++/Java.&#148; After arriving at the seminar, it slowly dawns on folks that the prerequisite of understanding C syntax is there for a very good reason. By including the CD ROM with the book, we can ensure that everyone attends a seminar with adequate preparation. <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Preface_20" title="Send BackTalk Comment">Feedback</a></font><br></p>
<p>The CD also allows the book to appeal to a wider audience. Even though Chapter 3 (Controlling Program Flow) does cover the fundamentals of the parts of Java that come from C, the CD is a gentler introduction, and assumes even less about the student&#146;s programming background than does the book. And being walked through the material in the first seven chapters via the corresponding lectures in the second edition of the <i>Hands-On Java </i>CD should help you get an even better foothold into Java. It is my hope that by including the CD, more people will be able to be brought into the fold of Java programming. The Hands-On Java CD ROM 3<sup>rd</sup> Edition is available only by ordering directly from the Web site <i>www.BruceEckel.com</i>. <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Preface_21" title="Send BackTalk Comment">Feedback</a></font><br></p>
<h2>
<a name="_Toc24775506"></a><a name="Heading873"></a>Source code</h2>
<p>All the source code for this book is available as copyrighted freeware, distributed as a single package, by visiting the Web site <a name="Index11"></a><a name="Index12"></a><i>www.BruceEckel.com</i>. To make sure that you get the most current version, this is the official site for distribution of the code and the electronic version of the book. You can find mirrored versions of the electronic book and the code on other sites (some of these sites are found at <i>www.BruceEckel.com</i>), but you should check the official site to ensure that the mirrored version is actually the most recent edition. You may distribute the code in classroom and other educational situations. <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Intro_67" title="Send BackTalk Comment">Feedback</a></font><br></p>
<p>The primary goal of the copyright is to ensure that the source of the code is properly cited, and to prevent you from republishing the code in print media without permission. (As long as the source is cited, using examples from the book in most media is generally not a problem.) <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Intro_68" title="Send BackTalk Comment">Feedback</a></font><br></p>
<p>In each source code file you will find a reference to the following copyright notice: <font size="-2"><a href="mailto:TIJ3@MindView.net?Subject=[TIJ3]Intro_69" title="Send BackTalk Comment">Feedback</a></font><br></p>

<BLOCKQUOTE><FONT SIZE = "+1"><PRE>This computer source code is Copyright &#169;2003 MindView, Inc.
All Rights Reserved.

Permission to use, copy, modify, and distribute <font color=#0000ff>this</font>
computer source code (Source Code) and its documentation
without fee and without a written agreement <font color=#0000ff>for</font> the
purposes set forth below is hereby granted, provided that
the above copyright notice, <font color=#0000ff>this</font> paragraph and the
following five numbered paragraphs appear in all copies.

1. Permission is granted to compile the Source Code and to

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -