Copyright © 1996 by Jamie Jaworski
HTML conversion by :
M/s. LeafWriters (India) Pvt. Ltd.
Website : http://leaf.stpn.soft.net
e-mail :
[email protected]
All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams.net Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Java is a trademark of Sun Microsystems, Inc.
President, Sams Publishing | Richard K. Swadley |
Publishing Manager | Mark Taber |
Managing Editor | Cindy Morrow |
Marketing Manager | John Pierce |
Assistant Marketing Manager | Kristina Perry |
Acquisitions Editor | Christopher Denny | Development Editor | L. Angelique Brittingham |
Software Development Specialist | Merle Newlon | Production Editor | Kitty Wilson |
Copy Editor | Kimberly K. Hannel | Technical Reviewer | Christopher M. Stone |
Editorial Coordinator | Bill Whitmer | Technical Edit Coordinator | Lynette Quinn |
Formatter | Frank Sinclair | Editorial Assistants | Carol Ackerman, Andi Richter, Rhonda Tinch-Mize, |
Cover Designer | Tim Amrhein | Book Designer | Alyssa Yesh |
Copy Writer | Peter Fuller | Production Team Supervisor | Brad Chinn |
Production | Mary Ann Abramson, Steve Adams, Georgiana Briggs, Mona Brown, Michael Brumitt, Charlotte Clapp, Jeanne Clark, Bruce Clingaman, Michael Dietsch, Sonja Hart, Jason Hand, Michael Henry, Ayanna Lacey, Clint Lahnen, Paula Lowell, Donna Martin, Steph Mineart, Dana Rhodes, Erich Richter, Craig Small, SA Springer, Mark Walchle |
I'd like to thank everyone who helped to see this book to completion. In particular, I'd like to thank George Stones for introducing me to Java, Margo Maley for making the book possible, and everyone at Sams.net for their great support. I'd also like to thank my co-author, Cary Jardin, for helping me finish the book closer to the scheduled deadline.
James Jaworski develops advanced systems for the United States Department of Defense. He has used Java in several research and development projects, including a terrain analysis program and a genetic algorithm demonstration.
Never before has a new programming language received so much attention and become so popular so quickly. In less than a year, Java evolved from experimental Alpha and Beta versions to its initial 1.0 release. Along the way, it took the Web by storm and became its adopted programming language. The Java phenomenon has captivated the imaginations of Web programmers and content developers and is leading the way toward the next era of Internet application development.
Java's appeal lies in its simplicity, its familiarity, and the careful selection of programming features that it includes and excludes. Java was not designed by a government committee or by a clique of academics. It shares the spirit of its birth with C more than any syntactical similarities. It is a programming language that was designed by programmers for programmers.
This book shows you how to program in Java. It covers all the details of the language, provides you with plenty of programming examples, and most importantly, arms you with the mindset needed to write Java code in a manner that is simple, efficient, and true to the nature of the language.
If you want someone to teach you how to program in Java, this book is for you. You will learn how to develop standalone Java programs, Java applets, and JavaScript applets. You will learn how to program window GUI controls, work with network sockets, and use stream-based input and output. You will learn to develop object-oriented programs and explore the breadth and depth of the Java application program interface. If you want to become a Java programmer, this book will show you how.
This book is for programmers and those who aspire to become Java programmers. It consists of 40 chapters that are filled with programming examples. If you have written programs in other languages, you will have the necessary background to understand the material presented in this book. If you have programmed in C or C++, then you will be able to quickly get up to speed with Java, since its syntax is based on these languages. If you have never programmed before, then you will have a difficult time using this book, because it assumes familiarity with basic programming concepts such as variables, types, statements, and expressions. I suggest that you pick up an introductory programming book to help you learn this material.
This book uses certain conventions that make it easier for you to use.
A monospaced font is used to identify program code. An italic monospaced font is used to identify placeholders used in Java syntax descriptions.
Note |
Notes like this are used to call your attention to information that is important to understanding and using Java. |
Tip |
Tips like this are used to identify ways that you can use Java more efficiently or take advantage of undocumented features in the Java Developer's Kit or Java-enabled browsers. |
Warning |
Warnings like this are used to help you to avoid common problems encountered when using Java and to keep you clear of potential programming difficulties. |
In order to help you understand where you are going and where you have been, each chapter begins with a short description of the information that will be presented and ends with a summary of the material that has been covered.
To use this book with the Java Developer's Kit, you'll need a computer and operating system that are capable of running Java 1.0. There are a wide variety of computers and operating systems that support Java, and Java continues to be ported to new hardware and software platforms.
To effectively use Java with Windows 95, you will need the following:
To effectively use this book, you will need access to a compact disc drive so that you can copy files from the enclosed CD. In addition, an Internet connection will be required to complete some of the networking examples, and a Java-enabled browser, such as Netscape 2.0 or later, will be needed to work with Java applets and JavaScript. A sound card and speakers will be needed to use audio-playing applets.
You can get started if you are able to run Windows 95 and have access to the Web. Chapter 2 shows you how to obtain the Java Developer's Kit from Sun's JavaSoft website. You can add additional hardware, as necessary, to complete the programming examples of each chapter.
The best way to use this book is to start with Chapter 1 and proceed through each chapter, in succession, working through each programming example that is presented. You will learn to program in Java by compiling, running, analyzing, and understanding the sample programs. Additional hands-on learning can be acquired by tinkering with the sample programs, modifying them, and augmenting their capabilities.