introduction.html

来自「java 是一个很好的网络开发环境。由于它是通过解释的方法」· HTML 代码 · 共 824 行 · 第 1/4 页

HTML
824
字号
didn’t seem to fit within the core of the book, and yet I find that I
discuss them during seminars. These are placed in the
appendices.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">Appendix A: 	<B><I>Using non-Java
code</I></B></FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">A totally portable Java program has
serious drawbacks: speed and the inability to access platform-specific services.
When you know the platform that you&#8217;re running on, it&#8217;s possible to
dramatically speed up certain operations by making them <I>native methods</I>,
which are functions that are written in another programming language (currently,
only C/C++ is supported). There are other ways that Java supports non-Java code,
including CORBA. This appendix gives you enough of an introduction to these
features that you should be able to create simple examples that interface with
non-Java code.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia"><I>Appendix</I> B:	<B><I>Comparing
C++ and Java</I></B></FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">If you&#8217;re a C++ programmer,
you already have the basic idea of object-oriented programming, and the syntax
of Java no doubt looks very familiar to you. This makes sense because Java was
derived from C++. However, there are a surprising number of differences between
C++ and Java. These differences are intended to be significant improvements, and
if you understand the differences you&#8217;ll see why Java is such a beneficial
programming language. This appendix takes you through the important features
that make Java distinct from C++.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">Appendix C:	<B><I>Java programming
guidelines</I></B></FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">This appendix contains suggestions
to help guide you while performing low-level program design and writing
code.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">Appendix
D:	<B><I>Performance</I></B></FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">This will allow you to find
bottlenecks and improve speed in your Java program.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">Appendix E:	<B><I>A bit about
garbage collection</I></B></FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">This appendix describes the
operation and approaches that are used to implement garbage
collection.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">Appendix F:	<B><I>Recommended
reading</I></B></FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">A list of some of the Java books
I&#8217;ve found particularly
useful.</FONT><A NAME="_Toc312373773"></A><A NAME="_Toc375545181"></A><A NAME="_Toc408018375"></A><BR></P></DIV>
<A NAME="Heading8"></A><FONT FACE = "Verdana"><H2 ALIGN="LEFT">
Exercises</H2></FONT>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">I&#8217;ve discovered that simple
exercises are exceptionally useful during a seminar to complete a
student&#8217;s understanding, so you&#8217;ll find a set at the end of each
chapter.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">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 exercises are more advanced to prevent
boredom for experienced students. The majority are designed to be solved in a
short time and test and polish your knowledge. Some are more challenging, but
none present major challenges. (Presumably, you&#8217;ll find those on your own
&#8211; or more likely they&#8217;ll find
you).</FONT><A NAME="_Ref310733137"></A><A NAME="_Toc312373774"></A><A NAME="_Toc375545182"></A><A NAME="_Toc408018376"></A><BR></P></DIV>
<A NAME="Heading9"></A><FONT FACE = "Verdana"><H2 ALIGN="LEFT">
Multimedia CD ROM<BR><A NAME="Index6"></A><A NAME="Index7"></A></H2></FONT>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">To accompany this book a Multimedia
CD ROM is available separately, but this is not like the CDs that you&#8217;ll
usually find packaged with books. Those often only contain the source code for
the book. (The code for this book is freely downloadable from the Web site
www.BruceEckel.com.) This CD ROM is a separate product and contains the
entire<B> </B>contents of the week-long &#8220;Hands-On Java&#8221; training
seminar. This is more than 15 hours of lectures given by Bruce Eckel,
synchronized with 500 slides of information. The seminar is based on this book
so it is an ideal accompaniment.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">The CD ROM contains two versions of
this book:</FONT><BR></P></DIV>
<OL>
<LI><FONT FACE="Georgia">	A printable version identical to the one
available for download. </FONT><LI><FONT FACE="Georgia">	For easy
on-screen viewing and reference, a screen-formatted and hyperlinked version
which is available exclusively on the CD-ROM. These hyperlinks include:
</FONT></OL><UL>
<LI><FONT FACE="Symbol" SIZE=4>	</FONT><FONT FACE="Georgia">230 chapter,
section, and sub-heading links
</FONT><LI><FONT FACE="Symbol" SIZE=4>	</FONT><FONT FACE="Georgia">3600
index links </FONT></UL><DIV ALIGN="LEFT"><P><FONT FACE="Georgia">The CD ROM
contains over 600MB of content. We believe that it sets a new standard for
value.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">The CD ROM contains everything in
the printable version of the book and everything (with the important exception
of personalized attention!) from the five-day full-immersion training seminars.
We believe that it sets a new standard for quality.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">The CD ROM is available only by
ordering directly from the Web site
www.BruceEckel.com.</FONT><A NAME="_Toc408018377"></A><BR></P></DIV>
<A NAME="Heading10"></A><FONT FACE = "Verdana"><H2 ALIGN="LEFT">
Source code</H2></FONT>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">All the source code for this book
is available as copyrighted freeware, distributed as a single package, by
visiting the Web site <I>http://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>http://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><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">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><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">In each <A NAME="Index8"></A>source
code file you will find the following copyright notice:</FONT><BR></P></DIV>

<BLOCKQUOTE><FONT SIZE = "+1"><PRE><font color=#009900>//////////////////////////////////////////////////</font>
<font color=#009900>// Copyright (c) Bruce Eckel, 1998</font>
<font color=#009900>// Source code file from the book "Thinking in Java"</font>
<font color=#009900>// All rights reserved EXCEPT as allowed by the</font>
<font color=#009900>// following statements: You can freely use this file</font>
<font color=#009900>// for your own work (personal or commercial),</font>
<font color=#009900>// including modifications and distribution in</font>
<font color=#009900>// executable form only. Permission is granted to use</font>
<font color=#009900>// this file in classroom situations, including its</font>
<font color=#009900>// use in presentation materials, as long as the book</font>
<font color=#009900>// "Thinking in Java" is cited as the source. </font>
<font color=#009900>// Except in classroom situations, you cannot copy</font>
<font color=#009900>// and distribute this code; instead, the sole</font>
<font color=#009900>// distribution point is http://www.BruceEckel.com </font>
<font color=#009900>// (and official mirror sites) where it is</font>
<font color=#009900>// freely available. You cannot remove this</font>
<font color=#009900>// copyright and notice. You cannot distribute</font>
<font color=#009900>// modified versions of the source code in this</font>
<font color=#009900>// package. You cannot use this file in printed</font>
<font color=#009900>// media without the express permission of the</font>
<font color=#009900>// author. Bruce Eckel makes no representation about</font>
<font color=#009900>// the suitability of this software for any purpose.</font>
<font color=#009900>// It is provided "as is" without express or implied</font>
<font color=#009900>// warranty of any kind, including any implied</font>
<font color=#009900>// warranty of merchantability, fitness for a</font>
<font color=#009900>// particular purpose or non-infringement. The entire</font>
<font color=#009900>// risk as to the quality and performance of the</font>
<font color=#009900>// software is with you. Bruce Eckel and the</font>
<font color=#009900>// publisher shall not be liable for any damages</font>
<font color=#009900>// suffered by you or any third party as a result of</font>
<font color=#009900>// using or distributing software. In no event will</font>
<font color=#009900>// Bruce Eckel or the publisher be liable for any</font>
<font color=#009900>// lost revenue, profit, or data, or for direct,</font>
<font color=#009900>// indirect, special, consequential, incidental, or</font>
<font color=#009900>// punitive damages, however caused and regardless of</font>
<font color=#009900>// the theory of liability, arising out of the use of</font>
<font color=#009900>// or inability to use software, even if Bruce Eckel</font>
<font color=#009900>// and the publisher have been advised of the</font>
<font color=#009900>// possibility of such damages. Should the software</font>
<font color=#009900>// prove defective, you assume the cost of all</font>
<font color=#009900>// necessary servicing, repair, or correction. If you</font>
<font color=#009900>// think you've found an error, please email all</font>
<font color=#009900>// modified files with clearly commented changes to:</font>
<font color=#009900>// Bruce@EckelObjects.com. (Please use the same</font>
<font color=#009900>// address for non-code errors found in the book.)</font>
<font color=#009900>/////////////////////////////////////////////////</font></PRE></FONT></BLOCKQUOTE>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">You may use the code in your
projects and in the classroom (including your presentation materials) as long as
the copyright notice that appears in each source file is
retained.</FONT><A NAME="_Toc312373775"></A><A NAME="_Toc375545183"></A><A NAME="_Toc408018378"></A><BR></P></DIV>
<A NAME="Heading11"></A><FONT FACE = "Verdana"><H3 ALIGN="LEFT">
Coding standards<BR><A NAME="Index9"></A><A NAME="Index10"></A></H3></FONT>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">In the text of this book,
identifiers (function, variable and class names) will be set in <B>bold</B>.
Most keywords will also be set in bold, except for those keywords that are used
so much that the bolding can become tedious, such as
&#8220;class.&#8221;</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">I use a particular coding style for
the examples in this book. This style seems to be supported by most Java
development environments. It was developed over a number of years, and was
inspired by Bjarne Stroustrup&#8217;s<A NAME="Index11"></A> style in his
original <I>The C++ Programming Language</I> (Addison-Wesley, 1991;
2<SUP>nd</SUP> ed.). The subject of formatting style is good for hours of hot
debate, so I&#8217;ll just say I&#8217;m not trying to dictate correct style via
my examples; I have my own motivation for using the style that I do. Because
Java is a free-form programming language, you can continue to use whatever style
you&#8217;re comfortable with.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">The programs in this book are files
that are included by the word processor in the text, directly from compiled
files. Thus, the code files printed in the book should all work without compiler
errors. The errors that <I>should</I> cause compile-time error messages are
commented out with the comment <B>//! </B>so they can be easily discovered and
tested using automatic means. Errors discovered and reported to the author will
appear first in the distributed source code and later in
<A NAME="Index12"></A><A NAME="Index13"></A>updates of the book (which will also
appear on the Web site
<I>http://www.BruceEckel.com</I>).</FONT><A NAME="_Toc312373778"></A><A NAME="_Toc375545184"></A><A NAME="_Toc408018379"></A><BR></P></DIV>
<A NAME="Heading12"></A><FONT FACE = "Verdana"><H2 ALIGN="LEFT">
Java
versions<BR><A NAME="Index14"></A><A NAME="Index15"></A><A NAME="Index16"></A><A NAME="Index17"></A><A NAME="Index18"></A></H2></FONT>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">Although I test the code in this
book with several different vendor implementations of Java, I generally rely on
the Sun implementation as a reference when determining whether behavior is
correct.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">By the time you read this, Sun will
have released three major versions of Java: 1.0, 1.1 and 1.2 (Sun says it will
make a major release about every nine months!). Version 1.1 represents a
significant change to the language and should probably have been labeled 2.0.
(And if 1.1 is such a big change from 1.0, I shudder to think what will justify
the number 2.0.) However, it&#8217;s version 1.2 that seems to finally bring
Java into the prime time, in particular where user interface tools are
concerned.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">This book covers versions 1.0, 1.1
and selected parts of 1.2, although in situations where a new approach is
clearly superior to the old, I definitely favor the new approach, often choosing
to teach the better approach and completely ignore the old approach. However,

⌨️ 快捷键说明

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