Home > Store

Java Tutorial, The: Object-Oriented Programming for the Internet, 2nd Edition

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

Java Tutorial, The: Object-Oriented Programming for the Internet, 2nd Edition

Book

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

About

Features

Java programming language. Written by two members of the JavaSoft team at Sun Microsystems, the book employs a hands-on interactive approach to teaching Java basics, object-oriented concepts, applet programming, and everything else you need to know to become a proficient Java programmer.

Through a task-oriented, example-driven approach, The Java Tutorial introduces you to fundamental concepts and applications. Designed so that you can customize your own path through the specific information you need, the book explains the nuts and bolts of the language, applet construction, and the fundamental Java classes. You will also learn about more advanced topics such as creating a graphical user interface (GUI), using multiple threads, and working with Java's networking capabilities.

This Second Edition has been extensively updated to cover API changes in Java 1.1 regarding UI, networking, and I/O, and to include the latest Java language developments. New and updated material includes:

  • receiving broadcasts using a multicast socket
  • new I/O features, including character streams and object serialization
  • the latest developments in applet tags
  • using the 1.1 AWT event system
  • new language features, such as nested classes
  • tips for writing 100% Pure Java programs
  • updating 1.0 programs to use the 1.1 API
In addition, the Second Edition has been revised and reorganized to offer a stronger and more cohesive presentation, making this best-selling and award-winning book even better. The Tutorial now starts with a new lesson that introduces you to the Java phenomenon and provides a foundation for understanding the rest of the book.

The accompanying CD-ROM contains the Tutorial and all its code samples, versions of the Java Development Kit (JDK) and the JDK documentation for each major platform, and the HotJava Browser. On the CD, the HTML version of the book is browser-friendly and contains information not found in the printed text, such as draft lessons on internationalizing Java programs, calling non-Java libraries from Java programs, using the security API, developing JavaBeans components, and using the GUI components in the Swing/JFC package.

Description

  • Copyright 1998
  • Dimensions: 7-3/8x9-1/4
  • Pages: 992
  • Edition: 2nd
  • Book
  • ISBN-10: 0-201-31007-4
  • ISBN-13: 978-0-201-31007-8

Third Edition
now available!

Follow your own path to expertise with this self-guided tour of the Java™ programming language. Written by two members of the JavaSoft team at Sun Microsystems, the book employs a hands-on interactive approach to teaching Java basics, object-oriented concepts, applet programming, and everything else you need to know to become a proficient Java programmer.

Through a task-oriented, example-driven approach, The Java™ Tutorial introduces you to fundamental concepts and applications. Designed so that you can customize your own path through the specific information you need, the book explains the nuts and bolts of the language, applet construction, and the fundamental Java classes. You will also learn about more advanced topics such as creating a graphical user interface (GUI), using multiple threads, and working with Java's networking capabilities.

This Second Edition has been extensively updated to cover API changes in Java 1.1 regarding UI, networking, and I/O, and to include the latest Java language developments. New and updated material includes:

  • receiving broadcasts using a multicast socket
  • new I/O features, including character streams and object serialization
  • the latest developments in applet tags
  • using the 1.1 AWT event system
  • new language features, such as nested classes
  • tips for writing 100% Pure Java programs
  • updating 1.0 programs to use the 1.1 API

In addition, the Second Edition has been revised and reorganized to offer a stronger and more cohesive presentation, making this best-selling and award-winning book even better. The Tutorial now starts with a new lesson that introduces you to the Java phenomenon and provides a foundation for understanding the rest of the book.

The accompanying CD-ROM contains the Tutorial and all its code samples, versions of the Java Development Kit™ (JDK) and the JDK documentation for each major platform, and the HotJava™ Browser. On the CD, the HTML version of the book is browser-friendly and contains information not found in the printed text, such as draft lessons on internationalizing Java programs, calling non-Java libraries from Java programs, using the security API, developing JavaBeans™ components, and using the GUI components in the Swing/JFC package.



0201310074B04062001

Sample Content

Table of Contents



Lesson 1. The Java Phenomenon.


Lesson 2. The "Hello World" Application.


Lesson 3. The "Hello World" Applet.

Common Problems (and Their Solutions). End of Trail. Learning the Java Language.



Lesson 4. Object-Oriented Programming Concepts.


Lesson 5. The Nuts and Bolts of the Java Language.


Lesson 6. Objects and Classes in Java.


Lesson 7. More Features of the Java Language.

Common Problems (and Their Solutions). End of Trail. Writing Applets.



Lesson 8. Overview of Applets.


Lesson 9. Taking Advantage of the Applet API.


Lesson 10. Practical Considerations of Writing Applets.


Lesson 11. Finishing an Applet.

Common Problems (and Their Solutions). End of Trail. Essential Java Classes.



Lesson 12. Using String and StringBuffer.


Lesson 13. Setting Program Attributes.


Lesson 14. Accessing System Resources.


Lesson 15. Handling Errors With Exceptions.


Lesson 16. Doing Two or More Tasks at Once: Threads.


Lesson 17. Reading and Writing (but no 'rithmetic).

End of Trail. Creating a User Interface.



Lesson 18. Overview of the Java UI.


Lesson 19. Using Components, the GUI Building Blocks.


Lesson 20. Laying Out Components Within a Container.


Lesson 21. Working with Graphics.

Common Problems (and Their Solutions). End of Trail. Custom Networking.



Lesson 22. Overview of Networking.


Lesson 23. Working with URLs.


Lesson 24. All About Sockets.


Lesson 25. All About Datagrams.

End of Trail. To 1.1--And Beyond!



Lesson 26. What's New in 1.1.


Lesson 27. Migrating to 1.1.


Lesson 28. A Preview of Things to Come.

End of Trail.



Appendix A: Code Examples.


Appendix B: Reference.


Index.

Preface

Since the release of the JDK 1.0.2 in May of 1996, the Java engineering team has been hard at work improving and enhancing the Java platform. We have been similarly laboring to update The Java Tutorial to reflect the work of the engineers. From the first page to the last, this edition now documents the APIs in JDK 1.1. We have fully integrated JDK 1.1 updates into the text, plus we've added coverage of some of the new features of 1.1 such as the new AWT event model, object serialization, and inner classes. We also added a new trail to the end of the book that provides a summary of what changed for 1.1, information to help you decide when to convert 1.0 programs to 1.1, and instructions about how to perform the conversion. And finally we've included a preview of what's likely to come in the next major release of the JDK.

Yet, this edition of The Java Tutorial is more than just an update of the previous edition. It's more polished and mature. We have rewritten, clarified, and reorganized many areas of the book based on feedback from readers and reviewers.

Like the first edition, this book is based on the online tutorial hosted at the Java Web site.

http://java.sun.com/docs/books/tutorial/index.html

The first draft of the online tutorial was made available in May 1995. At that time, it contained a few basic lessons on writing applets, the fundamentals of the language itself, and some key classes. Since then, the tutorial has grown to over 10MB of HMTL files, images, and running programs. It contains dozens of lessons covering topics ranging from applet communication to security, from internationalization to JavaBeansTM. We are constantly updating the online version of the tutorial to cover new APIs developed by the engineering team.

Like the online version, this book reflects the latest Java advances. However, unlike the online version, page count limits what this book can cover. Hence, it focuses on the Java APIs needed by most beginning to intermediate Java programmers. If you don't find information in this book about part of the Java platform, check our Web site for it.

From the online tutorial to the first edition, and from the first edition to the second, our intent has always been to create a fun, easy-to-read, task-oriented programmer's guide with lots of practical examples to help people learn to program in Java.

Who Should Read This Book?

This tutorial assumes that you have some programming experience, whether it be traditional procedural programming or object-oriented programming, and are familiar with programming tenets and terminology and at least one high-level language.

All Java programmers--novice and experienced alike--can benefit from this book. The first section begins with an overview of the Java platform and what it can help you do. It then presents two Java programs--one application and one applet--and shows you how to compile and run both. Finally, it describes how they work.

From this hands-on beginning, you can follow your own course of learning:

  • New programmers can benefit most by reading the book from beginning to end, including the beginning material on object-oriented concepts, the standard features of the Java language, and the object-oriented features of the Java language.
  • Programmers experienced with procedural languages such as C may wish to skip the section that describes the standard features of Java and start with the material on object-oriented concepts and the object-oriented features of Java.
  • Experienced object programmers may want to jump feet first into more advanced trails, such as those on applets, essential classes, or UIs.

No matter what type of programmer you are, you can find a path through this book that fits your learning requirements.

What You Need

This book documents the JDK 1.1 release of the Java platform. To compile and run the examples in this book you need a development environment that is compatible with JDK 1.1. You can use a commercially-available Java development environment or you can use the JDK itself.

You can use the version of JDK 1.1 that's on the CD-ROM accompanying this book. Or you might want to visit the Java Web side to download the latest version of the JDK:

http://java.sun.com/products/jdk/1.1/

If you are using the JDK provided by Sun Microsystems you will need one of the following systems:

  • Microsoft Windows 95/NT 4.0 running on Intel (or compatible) x86
  • Solaris 2.4, or 2.5 running on SPARC
  • Solaris 2.5 running on x86

If you are developing applets, you will need a browser that supports the 1.1 API. For testing applets, you can use a special limited browser called the Applet Viewer that ships with the JDK. For information about the browsers that are currently available and support 1.1, see the Web page for this book:

http://java.sun.com/docs/books/tutorial/2e/book.html

Finally, you need an editor that can save files in ASCII format with a .java extension. Also, the editor must allow you to specify both uppercase and lowercase letters in the filename.

Acknowledgments

For the Second Edition of the Tutorial

Many Internet readers have helped us maintain and improve the quality of the tutorial by sending us e-mail and cheerfully pointing out our numerous typos, broken links, and more importantly, areas of the tutorial that caused confusion or could benefit from rewriting.

Many members of the Java engineering and documentation team have given us counsel, answered our many questions, reviewed our material, and even made contributions to it. They also make JavaSoft a fun place to work. The list is long but we'd particularly like to note the contributions of Brian Beck, Joshua Bloch, David Connelly, Chris Darke, Bill Foote, Carol Hayes, Herb Jellinek, Doug Kramer, Marianne Mueller, Marla Parker, Mark Reinhold, John Rose, John Wegis, and Beth Whitman. Kathy would like to thank all the members of the Swing engineering team for being such a great group to work with. And, notably, Ron Mandel, who kept our Macs and PCs operating in a mostly Sun environment.

We are grateful for the other writers at Sun who have contributed to the online tutorial as guest authors. So far this list of professional and talented writers includes Mary Dageforde, Andy Quinn, Beth Stearns, and Greg Voss.

The Java language wouldn't exist without its creator, James Gosling. We'd like to thank James, not only for creating the language but also for staying involved as the Java platform develops. On a personal note, we'd like to thank him for accepting an award for us from JavaWorld (who named the tutorial as one of three finalists in the Best Training Aid category).

Our team managers, Lisa Friendly, Rick Levenson, and Stans Kleijnen, create a work environment that lets us get our job done. We especially appreciate their support of flexible, if a bit unusual, work arrangements.

Mike Hendrickson, our editorial advisor at Addison-Wesley, is always a calming influence and keeps us on schedule. Sarah Weaver was the production manager on the book and Laura Michaels was our copy editor and grammar queen. The whole team at Addison-Wesley have been a pleasure to work with and continually strive for excellence on this and the other books in the series.

Our heartfelt appreciation goes to the newest member of the tutorial team, Alison Huml, who calmly and professionally managed this edition of the book. She managed our schedule, handled the relationship with the copy editor, incorporated copy edits, drew or fixed many diagrams and images in the book, and handled all of the PC and Mac file conversions--all within the first month of working with us. Alison provides us with a fresh perspective and renewed energy. We look forward to her contributions to future book projects and to the online version of the tutorial.

For the First Edition of the Tutorial

Of course, the Java team made everything possible by creating Java in the first place. But many individuals contributed to getting this book out the door.

A million thanks go to the Java team members who answered questions, reviewed material, and in some cases, contributed examples--all of this in the face of tight deadlines: Thomas Ball, Brenda Bowden, David Brown, Patrick Chan, Tom Chavez, David Connelly, Pavani Diwanji, Amy Fowler, Jim Graham, Herb Jellinek, Jonni Kanerva, Doug Kramer, Eugene Kuerner, Tim Lindholm, Ron Mandel, Henry McGilton, Marianne Mueller, Scott Rautmann, Benjamin Renaud, Hassan Schroeder, Richard Scorer, Sami Shaio, Arthur van Hoff, Frank Yellin, and Steve Zellers.

Painful though they may have been, the feedback our reviewers provided us was invaluable. These reviewers were Mike Ballantyne, Richard Campione, Lee Collins, Greg Crisp, Matt Fahrner, Murali Ghanta, Bill Harts, Eileen Head, Murali Murugan, Roberto Quijalvo, Philip Resnik, Roger Riggs, Roman Rorat, Neil Sundaresan, Michael Weiss, the ones who preferred to remain anonymous, and all of the Internet readers who were kind enough to take the time to send us e-mail to let us know of problem areas.

Chris Warth spent several weeks writing scripts and filters to convert our complex web of HTML pages into MIF format. He was most patient with us despite our demands and changes. Marsh Chamberlain designed and created our trail icons, and Jan Kaerrman provided us with the html2ps script, which we used to create PostScript files from HTML and print our first review copy of the manuscript. Nathan Walrath created the figure in the Trail Map section. When we both went on maternity leave after giving the book to Addison-Wesley, Randy Nelson served as our backup, taking care of the CD-ROM and the Web site for the tutorial.

The staff at Addison-Wesley--Mike Hendrickson, Katie Duffy, Pamela Yee, and Marty Rabinowitz--were professional, competent, and courteous throughout the development of this book and provided us with guidance, encouragement, and instruction. They also managed the practical things like copy editing, page design, graphics, and reviewers so that all we had to do was worry about content.

Lisa Friendly, the Java Series editor, our manager, and our friend, made this book possible by suggesting that we turn the online tutorial into a book. She kept us calm, reassured us often, and managed everything, from our relationship with Addison-Wesley to consistency with other books in the series. Without her encouragement and hard work, this tutorial would not exist.

About the Dedication

Mary: This book is dedicated to my husband, Richard Campione, for being my greatest friend. It's also dedicated to Sophia, a delightful child and a constant reminder of what's truly important.

Kathy: This book is dedicated to my husband, Nathan Walrath, and to our children, Laine and Cosmo. Nathan has done whatever it takes to help me write this book, from distracting kids to dispensing advice and art criticism. Laine and Cosmo are not old enough to help--quite the opposite--but like their dad, they sure are fun.



0201310074P04062001

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