📄 tij0008.html
字号:
<html><body>
<table width="100%"><tr>
<td>
<a href="http://www.bruceeckel.com/javabook.html">Bruce Eckel's Thinking in Java</a>
</td>
<td align="right">
<a href="tij_c.html">Contents</a> | <a href="tij0007.html">Prev</a> | <a href="tij0009.html">Next</a>
</td>
</tr></table>
<hr>
<H2 ALIGN=LEFT>
Chapters</H2>
<DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">This
book was designed with one thing in mind: the way people learn the Java
language. Seminar audience feedback helped me understand which parts were
difficult and needed illumination. In the areas where I got ambitious and
included too many features all at once, I came to know – through the
process of presenting the material – that if you include a lot of new
features, you need to explain them all, and this easily compounds the
student’s confusion. As a result, I’ve taken a great deal of
trouble to introduce the features as few at a time as possible.
</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">The
goal, then, is for each chapter to teach a single feature, or a small group of
associated features, in such a way that no additional features are relied upon.
That way you can digest each piece in the context of your current knowledge
before moving on.
</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Here
is a brief description of the chapters contained in the book, which correspond
to lectures and exercise periods in my hands-on seminars.
</FONT><a name="OLE_LINK10"></a><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Chapter
1:
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B><I>Introduction
to objects
</I></B></FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">This
chapter is an overview of what object-oriented programming is all about,
including the answer to the basic question “What’s an
object?”, interface vs. implementation, abstraction and encapsulation,
messages and functions, inheritance and composition, and the all-important
polymorphism. You’ll also be introduced to issues of object creation such
as constructors, where the objects live, where to put them once they’re
created, and the magical garbage collector that cleans up the objects that are
no longer needed. Other issues will be introduced, including error handling
with exceptions, multithreading for responsive user interfaces, and networking
and the Internet. You’ll also learn about what makes Java special, why
it’s been so successful, and about object-oriented analysis and design.
</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Chapter
2:
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B><I> Everything
is an object
</I></B></FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">This
chapter moves you to the point where you can write your first Java program, so
it must give an overview of the essentials, including the concept of a
“handle” to an object; how to create an object; an introduction to
primitive types and arrays; scoping and the way objects are destroyed by the
garbage collector; how everything in Java is a new data type (class) and how to
create your own classes; functions, arguments, and return values; name
visibility and using components from other libraries; the
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>static</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
keyword; comments and embedded documentation.
</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Chapter
3:
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B><I>
Controlling
program flow
</I></B></FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">This
chapter begins with all of the operators that come to Java from C and C++. In
addition, you’ll discover common operator pitfalls, casting, promotion,
and precedence. This is followed by the basic control-flow and selection
operations that you get with virtually any programming language: choice with
if-else; looping with for and while; quitting a loop with break and continue as
well as Java’s labeled break and labeled continue (which account for the
“missing goto” in Java); and selection using switch. Although much
of this material has common threads with C and C++ code, there are some
differences. In addition, all the examples will be full Java examples so
you’ll get more comfortable with what Java looks like.
</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Chapter
4:
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B><I>
Initialization
and cleanup
</I></B></FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">This
chapter begins by introducing the constructor, which guarantees proper
initialization. The definition of the constructor leads into the concept of
function overloading (since you might want several constructors). This is
followed by a discussion of the process of cleanup, which is not always as
simple as it seems. Normally, you just drop an object when you’re done
with it and the garbage collector eventually comes along and releases the
memory. This portion explores the garbage collector and some of its
idiosyncrasies. The chapter concludes with a closer look at how things are
initialized: automatic member initialization, specifying member initialization,
the order of initialization,
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>static</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
initialization and array initialization.
</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Chapter
5:
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B><I>
Hiding
the implementation
</I></B></FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">This
chapter covers the way that code is packaged together, and why some parts of a
library are exposed while other parts are hidden. It begins by looking at the
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>package</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
and
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>import</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
keywords, which perform file-level packaging and allow you to build libraries
of classes. The subject of directory paths and file names is also examined. The
remainder of the chapter looks at the
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>public</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">,
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>private,</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
and
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>protected</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
keywords, the concept of “friendly” access, and what the different
levels of access control mean when used in various contexts.
</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Chapter
6:
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B><I>
Reusing
classes
</I></B></FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">The
concept of inheritance is standard in virtually all OOP languages. It’s a
way to take an existing class and add to its functionality (as well as change
it, the subject of Chapter 7). Inheritance is often a way to reuse code by
leaving the “base class” the same, and just patching things here
and there to produce what you want. However, inheritance isn’t the only
way to make new classes from existing ones. You can also embed an object inside
your new class with
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>composition</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">.
In this chapter you’ll learn about these two ways to reuse code in Java,
and how to apply them.
</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Chapter
7:
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B><I>
Polymorphism</I></B></FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">On
your own, you might take nine months to discover and understand polymorphism, a
cornerstone of OOP. Through small, simple examples you’ll see how to
create a family of types with inheritance and manipulate objects in that family
through their common base class. Java’s polymorphism allows you to treat
all objects in this family generically, which means the bulk of your code
doesn’t rely on specific type information. This makes your programs
extensible, so building programs and code maintenance is easier and cheaper. In
addition, Java provides a third way to set up a reuse relationship through the
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>interface</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">,
which is a pure abstraction of the interface of an object. Once you’ve
seen polymorphism, the interface can be clearly understood. This chapter also
introduces Java 1.1
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>inner
classes
</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">.</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Chapter
8:
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B><I>
Holding
your objects
</I></B></FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">It’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’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, anytime, anywhere. This chapter explores
in depth the tools that Java supplies to hold objects while you’re
working with them: the simple arrays and more sophisticated collections (data
structures) such as
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>Vector</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
and
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>Hashtable</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">.
Finally, the new and improved Java 1.2 collections library is explored in depth.
</FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Chapter
9:
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B><I>
Error
handling with exceptions
</I></B></FONT><P></DIV><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">The
basic philosophy of Java is that badly-formed code will not be run. As much as
possible, the compiler catches problems, but sometimes the problems –
either programmer error or a natural error condition that occurs as part of the
normal execution of the program – can be detected and dealt with only at
run-time. Java has
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><I>exception
handling
</I></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
to deal with any problems that arise while the program is running. This chapter
examines how the keywords
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>try</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">,
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>catch</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">,
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>throw</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">,
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>throws</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">,
and
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -