Home > Store

Thinking in Java, 2nd Edition

Register your product to gain access to bonus material or receive a coupon.

Thinking in Java, 2nd Edition

Book

  • Sorry, this book is no longer in print.
Not for Sale

About

Features

  • NEW - Unique, insightful, hard-hitting look at Java from the author of Thinking in C++ —Winner of 1995 Jolt Cola Award.
  • NEW - Java 2—Enterprise programming, Swing, servelets, and more!
  • NEW - Superb analogies—Comparing software concepts to everyday objects.
  • NEW - CD-ROM—Contains text and educational materials that new programmers will find very useful in bringing them up to speed in programming and Java.
  • NEW - The entire Thinking in C: Foundations for Java multimedia Seminar on CD-ROM enclosed with book.
  • NEW - For beginners and experts alike.
  • NEW - First edition covering Java 1 on CD-ROM is downloadable—www.BruceEckel.com.
  • NEW - Java linguistics—Not platform-dependent mechanics.
  • NEW - Thorough coverage of fundamentals—Demonstrates advanced topics.
  • NEW - Over 300 working Java programs—Over 15,000 lines of code.
  • NEW - Source code on the CD is downloadable.
  • NEW - Sound object-oriented principles—Eckel explains how they apply to Java.
  • NEW - Regular updates of this book and live seminars available online—www.BruceEckel.com.
  • NEW - The why of Java, not just the what of Java—Why Java was designed the way it was, why Java works the way it does, why Java sometimes doesn't work.

Description

  • Copyright 2000
  • Edition: 2nd
  • Book
  • ISBN-10: 0-13-027363-5
  • ISBN-13: 978-0-13-027363-5

The Definitive Introduction to Object-Oriented Programming in the Language of the World-Wide Web

Full text updates and code at HTTP://WWW.BRUCEECKEL.COM

JavaWorld Reader's Choice Award for best book, 2000
Java Developer's Journal Editor's Choice Award for best book, 1999
Software Development Magazine Productivity Award, 1999

From the fundamentals of Java syntax to its most advanced features (distributed computing, advanced object-oriented capabilities, multithreading), "Thinking in Java" is designed to teach. Bruce Eckel's readable style and small, direct programming examples make even the most arcane concepts clear.

  • Java 2 only!
  • First edition covering Java 1 on CD ROM and downloadable from www.BruceEckel.com
  • For beginners and experts alike.
  • Teaches Java linguistics, not platform-dependent mechanics.
  • Thorough coverage of fundamentals, demonstrates advanced topics.
  • 300+ working Java programs, 15,000+ lines of code.
  • Source code on the CD and downloadable.
  • Explains sound object-oriented principles as they apply to Java.
  • From an independent voice, award-winning author Bruce Eckel.
  • Regular updates of this book available of this book available online.
  • Companion CD with more than 15 hours of audio lectures by Bruce Eckel available online.
  • Live seminars available. See schedule at www.BruceEckel.com

What People Are Saying: "The best book on Java... Your depth is amazing," "Definitely the thinking person's choice in a Java book," "One of the absolutely best programming tutorials I've seen, for any language."

Sample Content

Downloadable Sample Chapter

Click here for a sample chapter for this book: 0130273635.pdf

Table of Contents

(NOTE: Each chapter concludes with Summary and Exercises.)

1. Introduction to Objects.

The Progress of Abstraction. An Object Has an Interface. The Hidden Implementation. Reusing the Implementation. Inheritance: Reusing the Interface. Is-A vs. Is-Like-A Relationships. Interchangeable Objects with Polymorphism. Abstract Base Classes and Interfaces. Object Landscapes and Lifetimes. Collections and Iterators. The Singly Rooted Hierarchy. Collection Libraries and Support for Easy Collection Use. Downcasting vs. Templates/Generics. The Housekeeping Dilemma: Who Should Clean Up? Garbage Collectors vs. Efficiency and Flexibility. Exception Handling: Dealing with Errors. Multithreading. Persistence. Java and the Internet. What Is the Web? Client/Server Computing. The Web as a Giant Server. Client-Side Programming. Plug-Ins. Scripting Languages. Java. Activex. Security. Internet vs. Intranet. Server-Side Programming. A Separate Arena: Applications. Analysis and Design. Phase 0: Make a Plan. The Mission Statement. Phase 1: What Are We Making? Phase 2: How Will We Build It? Five Stages of Object Design. Guidelines for Object Development. Phase 3: Build the Core. Phase 4: Iterate the Use Cases. Phase 5: Evolution. Plans Pay Off. Extreme Programming. Write Tests First. Pair Programming. Why Java Succeeds. Systems Are Easier to Express and Understand. Maximal Leverage with Libraries. Error Handling. Programming in the Large. Strategies for Transition. Guidelines. 1. Training. 2. Low-Risk Project. 3. Model from Success. 4. Use Existing Class Libraries. 5. Don't Rewrite Existing Code in Java. Management Obstacles. Startup Costs. Performance Issues. Common Design Errors. Java vs. C++?



2. Everything Is an Object.

You Manipulate Objects with References. You Must Create All the Objects. Where Storage Lives. Special Case: Primitive Types. High-Precision Numbers. Arrays in Java. You Never Need to Destroy an Object. Scoping. Scope of Objects. Creating New Data Types: Class. Fields and Methods. Default Values for Primitive Members. Methods, Arguments, and Return Values. The Argument List. Building a Java Program. Name Visibility. Using Other Components. The Static Keyword. Your First Java Program. Compiling and Running. Comments and Embedded Documentation. Comment Documentation. Syntax. Embedded HTML. @See: Referring to Other Classes. Class Documentation Tags. @Version. @Author. @Since. Variable Documentation Tags. Method Documentation Tags. @Param. @Return. @Throws. @Deprecated. Documentation Example. Coding Style.



3. Controlling Program Flow.

Using Java Operators. Precedence. Assignment. Aliasing during Method Calls. Mathematical Operators. Unary Minus and Plus Operators. Auto Increment and Decrement. Relational Operators. Testing Object Equivalence. Logical Operators. Short-Circuiting. Bitwise Operators. Shift Operators. Ternary If-Else Operator. The Comma Operator. String Operator +. Common Pitfalls When Using Operators. Casting Operators. Literals. Promotion. Java Has No “Sizeof.” Precedence Revisited. A Compendium of Operators. Execution Control. True and False. If-Else. Return. Iteration. Do-While. For. The Comma Operator. Break and Continue. The Infamous “Goto.” Switch. Calculation Details.



4. Initialization & Cleanup.

Guaranteed Initialization with the Constructor. Method Overloading. Distinguishing Overloaded Methods. Overloading with Primitives. Overloading on Return Values. Default Constructors. The This Keyword. Calling Constructors from Constructors. The Meaning of Static. Cleanup: Finalization and Garbage Collection. What Is Finalize( ) For? You Must Perform Cleanup. The Death Condition. How a Garbage Collector Works. Member Initialization. Specifying Initialization. Constructor Initialization. Order of Initialization. Static Data Initialization. Explicit Static Initialization. Non-Static Instance Initialization. Array Initialization. Multidimensional Arrays.



5. Hiding the Implementation.

Package: The Library Unit. Creating Unique Package Names. Collisions. A Custom Tool Library. Using Imports to Change Behavior. Package Caveat. Java Access Specifiers. “Friendly.” Public: Interface Access. The Default Package. Private: You Can't Touch That! Protected: “Sort of Friendly.” Interface and Implementation. Class Access.



6. Reusing Classes.

Composition Syntax. Inheritance Syntax. Initializing the Base Class. Constructors with Arguments. Catching Base Constructor Exceptions. Combining Composition and Inheritance. Guaranteeing Proper Cleanup. Order of Garbage Collection. Name Hiding. Choosing Composition vs. Inheritance. Protected. Incremental Development. Upcasting. Why “Upcasting”? Composition vs. Inheritance Revisited. The Final Keyword. Final Data. Blank Finals. Final Arguments. Final Methods. Final and Private. Final Classes. Final Caution. Initialization and Class Loading. Initialization with Inheritance.



7. Polymorphism.

Upcasting Revisited. Forgetting the Object Type. The Twist. Method-Call Binding. Producing the Right Behavior. Extensibility. Overriding vs. Overloading. Abstract Classes and Methods. Constructors and Polymorphism. Order of Constructor Calls. Inheritance and Finalize( ). Behavior of Polymorphic Methods Inside Constructors. Designing with Inheritance. Pure Inheritance vs. Extension. Downcasting and Run-Time Type Identification.



8. Interfaces & Inner Classes.

Interfaces. “Multiple Inheritance” in Java. Name Collisions When Combining Interfaces. Extending an Interface with Inheritance. Grouping Constants. Initializing Fields in Interfaces. Nesting Interfaces. Inner Classes. Inner Classes and Upcasting. Inner Classes in Methods and Scopes. Anonymous Inner Classes. The Link to the Outer Class. Static Inner Classes. Referring to the Outer Class Object. Reaching Outward from a Multiply-Nested Class. Inheriting from Inner Classes. Can Inner Classes Be Overridden? Inner Class Identifiers. Why Inner Classes? Closures & Callbacks. Inner Classes & Control Frameworks.



9. Holding Your Objects.

Arrays. Arrays are First-Class Objects. Containers of Primitives. Returning an Array. The Arrays Class. Filling an Array. Copying an Array. Comparing Arrays. Array Element Comparisons. Sorting an Array. Searching a Sorted Array. Array Summary. Introduction to Containers. Printing Containers. Filling Containers. Container Disadvantage: Unknown Type. Sometimes It Works Anyway. Making a Type-Conscious Arraylist. Parameterized Types. Iterators. Unintended Recursion. Container Taxonomy. Collection Functionality. List Functionality. Making a Stack from a Linkedlist. Making a Queue from a Linkedlist. Set Functionality. Sortedset. Map Functionality. Sortedmap. Hashing and Hash Codes. Understanding Hashcode( ). Hashmap Performance Factors. Overriding Hashcode( ). Holding References. The Weakhashmap. Iterators Revisited. Choosing an Implementation. Choosing between Lists. Choosing between Sets. Choosing between Maps. Sorting and Searching Lists. Utilities. Making a Collection or Map Unmodifiable. Synchronizing a Collection or Map. Fail Fast. Unsupported Operations. Java 1.0/1.1 Containers. Vector & Enumeration. Hashtable. Stack. Bitset.



10. Error Handling with Exceptions.

Basic Exceptions. Exception Arguments. Catching an Exception. The Try Block. Exception Handlers. Termination vs. Resumption. Creating Your Own Exceptions. The Exception Specification. Catching Any Exception. Rethrowing an Exception. Standard Java Exceptions. The Special Case of Runtimeexception. Performing Cleanup with Finally. What's Finally For? Pitfall: The Lost Exception. Exception Restrictions. Constructors. Exception Matching. Exception Guidelines.



11. The Java I/O System.

The File Class. A Directory Lister. Anonymous Inner Classes. Checking for and Creating Directories. Input and Output. Types of Inputstream. Types of Outputstream. Adding Attributes and Useful Interfaces. Reading from an Inputstream with Filterinputstream. Writing to an Outputstream with Filteroutputstream. Readers & Writers. Sources and Sinks of Data. Modifying Stream Behavior. Unchanged Classes. Off by Itself: Randomaccessfile. Typical Uses of I/O Streams. Input Streams: 1. Buffered Input File.2. Input from Memory.3. Formatted Memory Input.4. File Output. Output Streams:5. Storing and Recovering Data.6. Reading and Writing Random Access Files. A Bug? Piped Streams. Standard I/O. Reading from Standard Input. Changing System.Out to a Printwriter. Redirecting Standard I/O. Compression. Simple Compression with GZIP. Multifile Storage with Zip. Java Archives (Jars). Object Serialization. Finding the Class. Controlling Serialization. The Transient Keyword. An Alternative to Externalizable. Versioning. Using Persistence. Tokenizing Input. Streamtokenizer. Stringtokenizer. Checking Capitalization Style.



12. Run-Time Type Identification.

The Need for RTTI. The Class Object. Class Literals. Checking before a Cast. Using Class Literals. A Dynamic Instanceof. Instanceof vs. Class Equivalence. RTTI Syntax. Reflection: Run-Time Class Information. A Class Method Extractor.



13. Creating Windows & Applets.

The Basic Applet. Applet Restrictions. Applet Advantages. Application Frameworks. Running Applets inside a Web Browser. Using Appletviewer. Testing Applets. Running Applets From The Command Line. A Display Framework. Using the Windows Explorer. Making a Button. Capturing an Event. Text Areas. Controlling Layout. Borderlayout. Flowlayout. Gridlayout. Gridbaglayout. Absolute Positioning. Boxlayout. The Best Approach? The Swing Event Model. Event and Listener Types. Using Listener Adapters for Simplicity. Tracking Multiple Events. A Catalog of Swing Components. Buttons. Button Groups. Icons. Tool Tips. Text Fields. Borders. Jscrollpanes. A Mini-Editor. Check Boxes. Radio Buttons. Combo Boxes (Drop-Down Lists). List Boxes. Tabbed Panes. Message Boxes. Menus. Pop-Up Menus. Drawing. Dialog Boxes. File Dialogs. HTML on Swing Components. Sliders and Progress Bars. Trees. Tables. Selecting Look & Feel. The Clipboard. Packaging an Applet into a JAR File. Programming Techniques. Binding Events Dynamically. Separating Business Logic from UI Logic. A Canonical Form. Visual Programming and Beans. What Is a Bean? Extracting Beaninfo with the Introspector. A More Sophisticated Bean. Packaging a Bean. More Complex Bean Support. More to Beans.



14. Multiple Threads.

Responsive User Interfaces. Inheriting from Thread. Threading for a Responsive Interface. Combining the Thread with the Main Class. Making Many Threads. Daemon Threads. Sharing Limited Resources. Improperly Accessing Resources. How Java Shares Resources. Synchronizing the Counters. Synchronized Efficiency. Javabeans Revisited. Blocking. Becoming Blocked. Sleeping. Suspending and Resuming. Wait and Notify. Blocking On I/O. Testing. Deadlock. The Deprecation of Stop( ), Suspend( ), Resume( ), and Destroy( ) in Java. Priorities. Reading and Setting Priorities. Thread Groups. Controlling Thread Groups. Runnable Revisited. Too Many Threads.



15. Distributed Computing.

Network Programming. Identifying a Machine. Servers and Clients. Testing Programs without a Network. Port: A Unique Place within the Machine. Sockets. A Simple Server and Client. Serving Multiple Clients. Datagrams. Using Urls from within an Applet. Reading a File from the Server. More to Networking. Java Database Connectivity (JDBC). Getting the Example to Work. Step 1: Find the JDBC Driver. Step 2: Configure the Database. Step 3: Test the Configuration. Step 4: Generate Your SQL Query. Step 5: Modify and Paste in Your Query. A GUI Version of the Lookup Program. Why the JDBC API Seems So Complex. A More Sophisticated Example. Servlets. The Basic Servlet. Servlets and Multithreading. Handling Sessions with Servlets. The Cookie Class. The Session Class. Running the Servlet Examples. Java Server Pages. Implicit Objects. JSP Directives. JSP Scripting Elements. Extracting Fields and Values. JSP Page Attributes and Scope. Manipulating Sessions in JSP. Creating and Modifying Cookies. JSP Summary. RMI (Remote Method Invocation). Remote Interfaces. Implementing the Remote Interface. Setting Up the Registry. Creating Stubs and Skeletons. Using the Remote Object. CORBA. CORBA Fundamentals. CORBA Interface Definition Language (IDL). The Naming Service. An Example. Writing The IDL Source. Creating Stubs and Skeletons. Implementing the Server and the Client. Some CORBA Services. Activating the Name Service Process. Activating the Server and the Client. Java Applets and CORBA. CORBA vs. RMI. Enterprise Javabeans. Javabeans vs. Ejbs. The EJB Specification. EJB Components. EJB Container & Server. Java Naming and Directory Interface (JNDI). Java Transaction API/Java Transaction Service (JTA/JTS). CORBA and RMI/IIOP. The Pieces of an EJB Component. Enterprise Bean. Home Interface. Remote Interface. Deployment Descriptor. EJB-Jar File. EJB Operation. Types of Ejbs. Session Beans. Entity Beans. Developing an EJB. EJB Summary. Jini: Distributed Services. Jini in Context. What Is Jini? How Jini Works. The Discovery Process. The Join Process. The Lookup Process. Separation of Interface and Implementation. Abstracting Distributed Systems.



Appendix A: Passing & Returning Objects.

Passing References Around. Aliasing. Making Local Copies. Pass by Value. Cloning Objects. Adding Cloneability to a Class. Using a Trick with Protected. Implementing the Cloneable Interface. Successful Cloning. The Effect of Object.Clone( ). Cloning a Composed Object. A Deep Copy with Arraylist. Deep Copy via Serialization. Adding Cloneability Further Down a Hierarchy. Why This Strange Design? Controlling Cloneability. The Copy Constructor. Why Does It Work in C++ and Not Java? Read-Only Classes. Creating Read-Only Classes. The Drawback to Immutability. Immutable Strings. Implicit Constants. Overloading `+' and the Stringbuffer. The String and Stringbuffer Classes. Strings are Special.



Appendix B: The Java Native Interface (JNI).

Calling a Native Method. The Header File Generator: Javah. Name Mangling and Function Signatures. Implementing Your DLL. Accessing JNI Functions: The Jnienv Argument. Accessing Java Strings. Passing and Using Java Objects. JNI and Java Exceptions. JNI and Threading. Using a Preexisting Code Base. Additional Information.



Appendix C: Java Programming Guidelines.

Design. Implementation.



Appendix D: Resources.

Software. Books. Analysis & Design. Python. My Own List of Books.



Index.

Preface

Preface

I suggested to my brother Todd,who is making the leap from hardware into programming, that the next bigrevolution will be in genetic engineering.

We'll have microbes designed tomake food, fuel, and plastic; they'll clean up pollution and in generalallow us to master the manipulation of the physical world for a fraction of whatit costs now. I claimed that it would make the computer revolution look small incomparison.

Then I realized I was making a mistakecommon to science fiction writers: getting lost in the technology (which is ofcourse easy to do in science fiction). An experienced writer knows that thestory is never about the things; it's about the people. Genetics will havea very large impact on our lives, but I'm not so sure it will dwarf thecomputer revolution (which enables the genetic revolution)—or at least theinformation revolution. Information is about talking to each other: yes, carsand shoes and especially genetic cures are important, but in the end those arejust trappings. What truly matters is how we relate to the world. And so much ofthat is about communication.

This book is a case in point. A majorityof folks thought I was very bold or a little crazy to put the entire thing up onthe Web. "Why would anyone buy it?" they asked. If I had been of amore conservative nature I wouldn't have done it, but I reallydidn't want to write another computer book in the same old way. Ididn't know what would happen but it turned out to be the smartest thingI've ever done with a book.

For one thing, people started sending incorrections. This has been an amazing process, because folks have looked intoevery nook and cranny and caught both technical and grammatical errors, andI've been able to eliminate bugs of all sorts that I know would haveotherwise slipped through. People have been simply terrific about this, veryoften saying "Now, I don't mean this in a critical way..." andthen giving me a collection of errors I'm sure I never would have found. Ifeel like this has been a kind of group process and it has really made the bookinto something special.

But then I started hearing "OK,fine, it's nice you've put up an electronic version, but I want aprinted and bound copy from a real publisher." I tried very hard to makeit easy for everyone to print it out in a nice looking format but thatdidn't stem the demand for the published book. Most people don'twant to read the entire book on screen, and hauling around a sheaf of papers, nomatter how nicely printed, didn't appeal to them either. (Plus, I thinkit's not so cheap in terms of laser printer toner.) It seems that thecomputer revolution won't put publishers out of business, after all.However, one student suggested this may become a model for future publishing:books will be published on the Web first, and only if sufficient interestwarrants it will the book be put on paper. Currently, the great majority of allbooks are financial failures, and perhaps this new approach could make thepublishing industry more profitable.

This book became an enlighteningexperience for me in another way. I originally approached Java as "justanother programming language," which in many senses it is. But as timepassed and I studied it more deeply, I began to see that the fundamentalintention of this language is different from all the other languages I haveseen.

Programming is about managing complexity:the complexity of the problem you want to solve, laid upon the complexity of themachine in which it is solved. Because of this complexity, most of ourprogramming projects fail. And yet, of all the programming languages of which Iam aware, none of them have gone all-out and decided that their main design goalwould be to conquer the complexity of developing and maintainingprograms.1 Ofcourse, many language design decisions were made with complexity in mind, but atsome point there were always some other issues that were considered essential tobe added into the mix. Inevitably, those other issues are what cause programmersto eventually "hit the wall" with that language. For example, C++had to be backwards-compatible with C (to allow easy migration for Cprogrammers), as well as efficient. Those are both very useful goals and accountfor much of the success of C++, but they also expose extra complexity thatprevents some projects from being finished (certainly, you can blame programmersand management, but if a language can help by catching your mistakes, whyshouldn't it?). As another example, Visual Basic (VB) was tied to BASIC,which wasn't really designed to be an extensible language, so all theextensions piled upon VB have produced some truly horrible and unmaintainablesyntax. Perl is backwards-compatible with Awk, Sed, Grep, and other Unix toolsit was meant to replace, and as a result is often accused of producing"write-only code" (that is, after a few months you can't readit). On the other hand, C++, VB, Perl, and other languages like Smalltalk hadsome of their design efforts focused on the issue of complexity and as a resultare remarkably successful in solving certain types of problems.

What has impressed me most as I have cometo understand Java is what seems like an unflinching goal of reducing complexityfor the programmer. As if to say "we don't care aboutanything except reducing the time and difficulty of producing robustcode." In the early days, this goal has resulted in code thatdoesn't run very fast (although there have been many promises made abouthow quickly Java will someday run) but it has indeed produced amazing reductionsin development time; half or less of the time that it takes to create anequivalent C++ program. This result alone can save incredible amounts of timeand money, but Java doesn't stop there. It goes on to wrap all the complextasks that have become important, such as multithreading and networkprogramming, in language features or libraries that can at times make thosetasks trivial. And finally, it tackles some really big complexity problems:cross-platform programs, dynamic code changes, and even security, each of whichcan fit on your complexity spectrum anywhere from "impediment" to"show-stopper." So despite the performance problems we'veseen, the promise of Java is tremendous: it can make us significantly moreproductive programmers.

One of the places I see the greatestimpact for this is on the Web. Network programming has always been hard, andJava makes it easy (and the Java language designers are working on making iteven easier). Network programming is how we talk to each other more effectivelyand cheaper than we ever have with telephones (email alone has revolutionizedmany businesses). As we talk to each other more, amazing things begin to happen,possibly more amazing even than the promise of geneticengineering.

In all ways—creating the programs,working in teams to create the programs, building user interfaces so theprograms can communicate with the user, running the programs on different typesof machines, and easily writing programs that communicate across theInternet—Java increases the communication bandwidth between people.I think that perhaps the results of the communication revolution will not beseen from the effects of moving large quantities of bits around; we shall seethe true revolution because we will all be able to talk to each other moreeasily: one-on-one, but also in groups and, as a planet. I've heard it suggestedthat the next revolution is the formation of a kind of global mind that resultsfrom enough people and enough interconnectedness. Java may or may not be thetool that foments that revolution, but at least the possibility has made me feellike I'm doing something meaningful by attempting to teach thelanguage.

Preface to the 2nd edition

People have made many, many wonderfulcomments about the first edition of this book, which has naturally been verypleasant for me. However, every now and then someone will have complaints, andfor some reason one complaint that comes up periodically is "the book istoo big." In my mind it is faint damnation indeed if "too manypages" is your only complaint. (One is reminded of the Emperor ofAustria's complaint about Mozart's work: "Too manynotes!" Not that I am in any way trying to compare myself to Mozart.) Inaddition, I can only assume that such a complaint comes from someone who is yetto be acquainted with the vastness of the Java language itself, and has not seenthe rest of the books on the subject—for example, my favorite reference isCay Horstmann & Gary Cornell's Core Java (Prentice-Hall), whichgrew so big it had to be broken into two volumes. Despite this, one of thethings I have attempted to do in this edition is trim out the portions that havebecome obsolete, or at least nonessential. I feel comfortable doing this becausethe original material remains on the Web site and the CD ROM that accompaniesthis book, in the form of the freely-downloadable first edition of the book (atwww.BruceEckel.com). If you want the old stuff, it's still there,and this is a wonderful relief for an author. For example, you may notice thatthe original last chapter, "Projects," is no longer here; two of theprojects have been integrated into other chapters, and the rest were no longerappropriate. Also, the "Design Pattens" chapter became too big andhas been moved into a book of its own (also downloadable at the Web site). So,by all rights the book should be thinner.

But alas, it is not tobe.

The biggest issue is the continuingdevelopment of the Java language itself, and in particular the expanding APIsthat promise to provide standard interfaces for just about everythingyou'd like to do (and I won't be surprised to see the"JToaster" API eventually appear). Covering all these APIs isobviously beyond the scope of this book and is a task relegated to otherauthors, but some issues cannot be ignored. The biggest of these includeserver-side Java (primarily Servlets & Java Server pages, or JSPs),which is truly an excellent solution to the World Wide Web problem, whereinwe've discovered that the various Web browser platforms are just notconsistent enough to support client-side programming. In addition, there is thewhole problem of easily creating applications to interact with databases,transactions, security, and the like, which is involved with Enterprise JavaBeans (EJBs). These topics are wrapped into the chapter formerly called"Network Programming" and now called "DistributedComputing," a subject that is becoming essential to everyone. You'llalso find this chapter has been expanded to include an overview of Jini(pronounced "genie," and it isn't an acronym, just a name),which is a cutting-edge technology that allows us to change the way we thinkabout interconnected applications. And of course the book has been changed touse the Swing GUI library throughout. Again, if you want the old Java 1.0/1.1stuff you can get it from the freely-downloadable book atwww.BruceEckel.com (it is also included on this edition's new CDROM, bound into the book; more on that a little later).

Aside from additional small languagefeatures added in Java 2 and corrections made throughout the book, the othermajor change is in the collections chapter (9), which now focuses on the Java 2collections used throughout the book. I've also improved that chapter tomore deeply go into some of the important issues of collections, in particularhow a hash function works (so that you can know how to properly create one).There have been other movements and changes, including a rewrite of Chapter 1,and removal of some appendices and other material that I consider no longernecessary for the printed book, but those are the bulk of them. In general,I've tried to go over everything, remove from the 2nd editionwhat is no longer necessary (but which still exists in the electronic firstedition), include changes, and improve everything I could. As the languagecontinues to change—albeit not quite at the same breakneck pace asbefore—there will no doubt be further editions of thisbook.

For those of you who still can'tstand the size of the book, I do apologize. Believe it or not, I have workedhard to keep it small. Despite the bulk, I feel like there may be enoughalternatives to satisfy you. For one thing, the book is available electronically(from the Web site, and also on the CD ROM that accompanies this book), so ifyou carry your laptop you can carry the book on that with no extra weight. Ifyou're really into slimming down, there are actually Palm Pilot versionsof the book floating around. (One person told me he would read the book in bedon his Palm with the backlighting on to keep from annoying his wife. I can onlyhope that it helps send him to slumberland.) If you need it on paper, I know ofpeople who print a chapter at a time and carry it in their briefcase to read onthe train.

Java 2

At this writing, the release ofSun's Java Development Kit (JDK) 1.3 is imminent, and the proposedchanges for JDK 1.4 have been publicized. Although these version numbers arestill in the "ones," the standard way to refer to any version of thelanguage that is JDK 1.2 or greater is to call it "Java 2." Thisindicates the very significant changes between "oldJava"—which had many warts that I complained about in the firstedition of this book—and this more modern and improved version of thelanguage, which has far fewer warts and many additions and nicedesigns.

This book is written for Java 2. I havethe great luxury of getting rid of all the old stuff and writing to only thenew, improved language because the old information still exists in theelectronic 1st edition on the Web and on the CD ROM (which is whereyou can go if you're stuck using a pre-Java-2 version of the language).Also, because anyone can freely download the JDK from java.sun.com, it meansthat by writing to Java 2 I'm not imposing a financial hardship on someoneby forcing them to upgrade.

There is a bit of a catch, however. JDK1.3 has some improvements that I'd really like to use, but the version ofJava that is currently being released for Linux is JDK 1.2.2. Linux (seewww.Linux.org) is a very important development in conjunction with Java, becauseit is fast becoming the most important server platform out there—fast,reliable, robust, secure, well-maintained, and free, a true revolution in thehistory of computing (I don't think we've ever seen all of thosefeatures in any tool before). And Java has found a very important niche inserver-side programming in the form of Servlets, a technology that is ahuge improvement over the traditional CGI programming (this is covered in the"Distributed Programming" chapter).

So although I would like to only use thevery newest features, it's critical that everything compiles under Linux,and so when you unpack the source code and compile it under that OS (with thelatest JDK) you'll discover that everything will compile. However, youwill find that I've put notes about features in JDK 1.3 here andthere.

The CD ROM

Another bonus with this edition is the CDROM that is packaged in the back of the book. I've resisted putting CDROMs in the back of my books in the past because I felt the extra charge for afew Kbytes of source code on this enormous CD was not justified, preferringinstead to allow people to download such things from my Web site. However,you'll soon see that this CD ROM is different.

The CD does contain the source code fromthe book, but it also contains the book in its entirety, in several electronicformats. My favorite of these is the HTML format, because it is fast and fullyindexed—you just click on an entry in the index or table of contents andyou're immediately at that portion of the book.

The bulk of the 300+ Megabytes of the CD,however, is a full multimedia course called Thinking in C: Foundations forC++ & Java. I originally commissioned Chuck Allison to create thisseminar-on-CD ROM as a stand-alone product, but decided to include it with thesecond editions of both Thinking in C++ and Thinking in Javabecause of the consistent experience of having people come to seminars withoutan adequate background in C. The thinking apparently goes "I'm asmart programmer and I don't want to learn C, but rather C++ orJava, so I'll just skip C and go directly to C++/Java." Afterarriving at the seminar, it slowly dawns on folks that the prerequisite ofunderstanding C syntax is there for a very good reason. By including the CD ROMwith the book, we can ensure that everyone attends a seminar with adequatepreparation.

The CD also allows the book to appeal toa wider audience. Even though Chapter 3 (Controlling program flow) does coverthe fundamentals of the parts of Java that come from C, the CD is a gentlerintroduction, and assumes even less about the student's programmingbackground than does the book. It is my hope that by including the CD morepeople will be able to be brought into the fold of Javaprogramming.


1I take this back on the 2nd edition: I believe that the Pythonlanguage comes closest to doing exactly that. Seewww.Python.org

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020