New to Java? We'll help you get started with our revised beginner's tutorial, or our free online textbook.
Get the latest Java books h t t p : / /w w w . j a v a c o f f e e b r e a k . c o m /
Introduction to Programming Using Java, Third Edition
Preface
"INTRODUCTION TO PROGRAMMING WITH JAVA" is a free, on-line textbook. It is suitable for use in an introductory programming course and for people who are trying to learn programming on their own. There are no prerequisites beyond a general familiarity with the ideas of computers and programs.
This text uses the Java programming language as the language of instruction. It requires Java version 1.1 or higher. In style, this is a textbook rather than a tutorial. That is, it concentrates on explaining concepts rather than giving step-by-step how-to-do-it guides. It is certainly not a Java reference book, and it is not even a comprehensive survey of all the features of Java. It is not a quick introduction to Java for people who already know another programming language. Instead, it is directed mainly towards people who are learning programming for the first time, and it is as much about general programming concepts as it is about Java in particular.
This is the third edition of Introduction to Programming with Java. The first two editions have been used by the author and by another professor in the introductory programming class at Hobart and William Smith Colleges (http://www.hws.edu/). The new edition is a major upgrade. It is more than twice the size of the second edition. Changes include:
- Chapter 11, on linked data structures and recursion, is completely new. Chapter 9, on correctness and robustness, is new except for the section on the try...catch statement.
- A single chapter on "programming in the small" from the previous edition has been expanded to two chapters (Chapter 2 and Chapter 3) in this edition.
- Every chapter, except the first, now includes a set of programming exercises. A solution is provided for each exercise, along with a discussion of the programming involved.
- There is a sample quiz at the end of each chapter, with answers.
- Many sections from the previous edition have been rewritten, and many new examples have been added. As in the previous editions, the source code for every example is included in an appendix.
- Based on experience with the previous editions, the exposition of some topics has been modified by postponing certain details until later in the text. This is especially true in the two chapters on graphical user interface programming (Chapter 6 and Chapter 7 in this edition). These chapters have been completely reorganized.
With these changes, Introduction to Programming with Java is now fully competitive, in the author's opinion, with the conventionally published, printed programming textbooks that are available on the market. (Well, all right, I'll confess that I think it's better.)
This textbook differs from many other Java programming books in that it does not deal primarily with applets. Early chapters concentrate on standalone applications that use text input and output. Applets are introduced briefly in Section 3.7 and covered pretty thoroughly in Chapter 6 and Chapter 7. In the remaining chapters, applets are used in many but not all examples and exercises. "Swing," a new set of interface components introduced in Java 1.2, is just barely mentioned (in Section 7.8). This approach allows a gentler introduction to fundamental programming concepts, and it postpones the complexities of graphical user interface programming until a time when students are ready to deal with them. The decision to do things this way also reflects the fact that applets are only one aspect of Java, and probably not the most important.
I do not plan any further major upgrades to this textbook, but I will probably release new versions in the future with minor revisions and corrections. The current edition of Introduction to Programming with Java will always be available at the following Web address:
http://math.hws.edu/javanotes/
The first, second, and third editions are permanently archived at the following addresses:
First edition: http://math.hws.edu/eck/cs124/javanotes1/
Second edition: http://math.hws.edu/eck/cs124/javanotes2/
Third edition: http://math.hws.edu/eck/cs124/javanotes3/
Downloading the Text
The complete Introduction to Programming with Java is available for download as a compressed archive for the Windows, Macintosh, or Linux/Unix platforms. (Text files have slightly different formats on the three platforms. The text files in each archive are in the appropriate format for the platform. For many purposes, though, the difference is unimportant. For example, Web browsers will accept files in any of the formats.) The uncompressed archives contain 580 files and directories and take up over four megabytes of space. You should be able to download an archive by clicking on one of the following links. If you have problems with the downloading, please let me know!
- http://math.hws.edu/eck/cs124/downloads/javanotes3.zip (1.6 MB), for Windows.
- http://math.hws.edu/eck/cs124/downloads/javanotes3.sit.hqx (2.1 MB), for Macintosh.
- http://math.hws.edu/eck/cs124/downloads/javanotes3.tar.Z (1.8 MB), for Linux/UNIX.
An archive must be uncompressed to be useful. To do this, you will need appropriate software (which might already be on your computer). For Windows, you can use WinZip, available from www.winzip.com. WinZip is shareware, but you can use it for a 30 day trial without charge. Alternatively, you might want to get the free program, Aladdin Expander for Windows from www.aladdinsys.com, which can also be used to uncompress the Windows archive. For Macintosh, you need Stuffit Expander for Macintosh, which is already included with most Web browsers. In fact, your Web browser might uncompress the archive automatically when you download it. If you don't have it, Stuffit Expander can be downloaded from www.aladdinsys.com. The software for Linux/UNIX should already be included on your system. To decode the archive javanotes3.tar.Z, use the command "uncompress javanotes3.tar.Z" followed by the command "tar xf javanotes3.tar".
I recommend reading Introduction to Programming with Java with a Web browser, so that you can see and use the applets that occur throughout the text. However, I know from experience that a lot of people will want to print all or part of the text. To make this a little easier, I've made a large PDF file that contains the entire textbook, except for the Java source code files from Appendix 3 and the solutions to the quizzes and programming exercises. Of course, the PDF file does not display the applets in the text. Where they should appear, you'll generally see a message such as "Sorry, but your browser does not support Java." A PDF file can be viewed or printed using the free program, Adobe Acrobat Reader. (The file was created using the "Web Capture" feature in Adobe Acrobat Pro 4.0.) The PDF file is available through the following link. It is more than 1.8 megabytes in size, and it contains more than 500 pages of text.
If there is a PDF viewer built into your browser, clicking on the above link will show the file in your Web browser window. In that case, to download the file, try right-clicking or Control-clicking the link. This should bring up a menu that contains a command such as "Save this link". Selecting that command will allow you to download the file to your hard disk.
Usage Restrictions
Introduction to Programming with Java is free, but it is not in the public domain. Permission is hereby granted to use this on-line textbook in any of the following ways:
- Complete, unmodified copies of this work can be redistributed in any form and posted on Web sites, including globally accessible Web sites. This includes commercial redistribution. The copy must, in particular, include the "welcome page," including the reference on that page to the main Web site for this text, http://math.hws.edu/javanotes/. The intention is that readers should understand that the work is freely available on the Internet.
- An unmodified copy of a part of this work can be redistributed in any form and posted on Web sites, including globally accessible Web sites, provided that the source of the material is clearly and prominently explained. Materials posted on the Web must include a link to the main Web site for this text, http://math.hws.edu/javanotes/. Printed materials must include this Web address.
- Teachers can make modified versions of this work or of parts of this work for use in their courses, provided that: they are only distributed locally; they include prohibitions on further redistribution by users; and they clearly explain the source of the material. These materials can be posted on a Web site, as long as access is restricted to a local network.
Anyone who wants to use this work, or a part of it, in any other way should contact the author.
Professor David J. Eck
Department of Mathematics and Computer Science
Hobart and William Smith Colleges
Geneva, New York 14456, USA
Email: eck@hws.edu
WWW: http://math.hws.edu/eck/
May 23, 2000