Thinking in Java - 4th Edition
1079 pág.

Thinking in Java - 4th Edition

Disciplina:Programação Orientada A Objetos2.096 materiais40.928 seguidores
Pré-visualização50 páginas
Thinking in C multimedia seminar that you can download from www.MindView.net will
bring you up to speed in the fundamentals necessary to learn Java. However, I will be
introducing the concepts of object-oriented programming (OOP) and Java’s basic control
mechanisms.

Although references may be made to C and C++ language features, these are not intended to
be insider comments, but instead to help all programmers put Java in perspective with those
languages, from which, after all, Java is descended. I will attempt to make these references
simple and to explain anything that I think a non-C/C++ programmer would not be familiar
with.

 

Learning Java
At about the same time that my first book, Using C++ (Osborne/McGraw-Hill, 1989), came
out, I began teaching that language. Teaching programming ideas has become my profession;
I’ve seen nodding heads, blank faces, and puzzled expressions in audiences all over the world
since 1987. As I began giving in-house training with smaller groups of people, I discovered
something during the exercises. Even those people who were smiling and nodding were
confused about many issues. I found out, by creating and chairing the C++ track at the
Software Development Conference for a number of years (and later creating and chairing the
Java track), that I and other speakers tended to give the typical audience too many topics too
quickly. So eventually, through both variety in the audience level and the way that I
presented the material, I would end up losing some portion of the audience. Maybe it’s
asking too much, but because I am one of those people resistant to traditional lecturing (and
for most people, I believe, such resistance results from boredom), I wanted to try to keep
everyone up to speed.

For a time, I was creating a number of different presentations in fairly short order. Thus, I
ended up learning by experiment and iteration (a technique that also works well in program
design). Eventually, I developed a course using everything I had learned from my teaching
experience. My company, MindView, Inc., now gives this as the public and in-house Thinking
in Java seminar; this is our main introductory seminar that provides the foundation for our
more advanced seminars. You can find details at www.MindView.net. (The introductory
seminar is also available as the Hands-On Java CD ROM. Information is available at the
same Web site.)

The feedback that I get from each seminar helps me change and refocus the material until I
think it works well as a teaching medium. But this book isn’t just seminar notes; I tried to
pack as much information as I could within these pages, and structured it to draw you
through into the next subject. More than anything, the book is designed to serve the solitary
reader who is struggling with a new programming language.

Goals
Like my previous book, Thinking in C++, this book was designed with one thing in mind: the
way people learn a language. When I think of a chapter in the book, I think in terms of what
makes a good lesson during a seminar. Seminar audience feedback helped me understand the
difficult parts that 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.

Each chapter tries to teach a single feature, or a small group of associated features, without
relying on concepts that haven’t been introduced yet. That way you can digest each piece in
the context of your current knowledge before moving on.

My goals in this book are to:

1. Present the material one simple step at a time so that you can easily digest each idea
before moving on. Carefully sequence the presentation of features so that you’re
exposed to a topic before you see it in use. Of course, this isn’t always possible; in
those situations, a brief introductory description is given.

2. Use examples that are as simple and short as possible. This sometimes prevents me
from tackling “real world” problems, but I’ve found that beginners are usually happier
when they can understand every detail of an example rather than being impressed by

10 Thinking in Java Bruce Eckel

the scope of the problem it solves. Also, there’s a severe limit to the amount of code
that can be absorbed in a classroom situation. For this I will no doubt receive criticism
for using “toy examples,” but I’m willing to accept that in favor of producing
something pedagogically useful.

3. Give you what I think is important for you to understand about the language, rather

than everything that I know. I believe there is an information importance hierarchy,
and that there are some facts that 95 percent of programmers will never need to
know—details that just confuse people and increase their perception of the complexity
of the language. To take an example from C, if you memorize the operator precedence
table (I never did), you can write clever code. But if you need to think about it, it will
also confuse the reader/maintainer of that code. So forget about precedence, and use
parentheses when things aren’t clear.

4. Keep each section focused enough so that the lecture time—and the time between

exercise periods—is small. Not only does this keep the audience’s minds more active
and involved during a hands-on seminar, but it gives the reader a greater sense of
accomplishment.

5. Provide you with a solid foundation so that you can understand the issues well enough

to move on to more difficult coursework and books.

Teaching from this book
The original edition of this book evolved from a one-week seminar which was, when Java was
in its infancy, enough time to cover the language. As Java grew and continued to encompass
more and more features and libraries, I stubbornly tried to teach it all in one week. At one
point, a customer asked me to teach “just the fundamentals,” and in doing so I discovered
that trying to cram everything into a single week had become painful for both myself and for
seminarians. Java was no longer a “simple” language that could be taught in a week.

That experience and realization drove much of the reorganization of this book, which is now
designed to support a two-week seminar or a two-term college course. The introductory
portion ends with the Error Handling with Exceptions chapter, but you may also want to
supplement this with an introduction to JDBC, Servlets and JSPs. This provides a foundation
course, and is the core of the Hands-On Java CD ROM. The remainder of the book comprises
an intermediatelevel course, and is the material covered in the Intermediate Thinking in
Java CD ROM. Both of these CD ROMs are for sale at www.MindView.net.

Contact Prentice-Hall at www.prenhallprofessional.com for information about professor
support materials for this book.

JDK HTML documentation
The Java language and libraries from Sun Microsystems (a free download from
http://java.sun.com) come with documentation in electronic form, readable using a Web
browser. Many books published on Java have duplicated this documentation. So you either
already have it or you can download it, and unless necessary, this book will not repeat that
documentation, because it’s usually much faster if you find the class descriptions with your
Web browser than if you look them up in a book (and the online documentation is probably
more upto-date). You’ll simply be referred to “the JDK documentation.” This book will
provide extra descriptions of the classes only when it’s necessary to supplement that
documentation so you can understand a particular example.

Introduction 11 

Exercises
I’ve discovered that simple exercises are exceptionally useful to complete a student’s
understanding during a seminar, so you’ll find a set at the end of each chapter.

Most