Introduction
He gave man speech, and speech created thought, Which is the measure of the UniversePrometheus Unbound, Shelley
Human beings ... are very much at the mercy of the particular language which has become the medium of expression for their society. It is quite an illusion to imagine that one adjusts to reality essentially without the use of language and that language is merely an incidental means of solving specific problems of communication and reflection. The fact of the matter is that the "real world" is to a large extent unconsciously built up on the language habits of the group.
The Status Of Linguistics As A Science, 1929, Edward Sapir
Like any human language, Java provides a way to express concepts. If successful, this medium of expression will be significantly easier and more flexible than the alternatives as problems grow larger and more complex.
You cant look at Java as just a collection of featuressome of the features make no sense in isolation. You can use the sum of the parts only if you are thinking about design, not simply coding. And to understand Java in this way, you must understand the problems with it and with programming in general. This book discusses programming problems, why they are problems, and the approach Java has taken to solve them. Thus, the set of features that I explain in each chapter are based on the way I see a particular type of problem being solved with the language. In this way I hope to move you, a little at a time, to the point where the Java mindset becomes your native tongue.
Throughout, Ill be taking the attitude that you want to build a model in your head that allows you to develop a deep understanding of the language; if you encounter a puzzle, youll be able to feed it to your model and deduce the answer.
Prerequisites
This book assumes that you have some programming familiarity: you understand that a program is a collection of statements, the idea of a subroutine/function/macro, control statements such as if and looping constructs such as while, etc. However, you might have learned this in many places, such as programming with a macro language or working with a tool like Perl. As long as youve programmed to the point where you feel comfortable with the basic ideas of programming, youll be able to work through this book. Of course, the book will be easier for the C programmers and more so for the C++ programmers, so dont count yourself out if youre not experienced with those languagesbut come willing to work hard (also, the multimedia CD that accompanies this book 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 Javas basic control mechanisms.
Although references will often 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.