Java Programming
About the Author
Poornachandra Sarang (popularly known as Dr. Sarang) has been a Java programmer since its inception way back in 1996. Over the last 15 years, Dr. Sarang has conducted many train-the-trainer programs, instructor authorization tests, and corporate training sessions based on Sun Microsystems official curriculum. He has authored several books and journal articles on Java and various other similar topics. He has been a regular speaker at many international conferences, including the recent JavaOne 2011. He is also associated with the University of Mumbai and a few other universities of repute as a visiting/adjunct faculty and Ph.D. advisor in Computer Science. Dr. Sarang has been invited to deliver keynote addresses and technical talks at many international research and technology conferences. Besides Java coding, Dr. Sarang does some architecture work and is also well recognized in the Enterprise Architecture space.
Java Programming
Poornachandra Sarang
New York Chicago San Francisco
Lisbon London Madrid Mexico City Milan
New Delhi San Juan Seoul Singapore Sydney Toronto
Cataloging-in-Publication Data is on file with the Library of Congress
Java Programming
Copyright 2012 by The McGraw-Hill Companies, Inc. All rights reserved. Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher.
ISBN: 978-0-07-163361-1
MHID: 0-07-163361-8
The material in this eBook also appears in the print version of this title: ISBN 978-0-07-163360-4, MHID 0-07-163360-X.
All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trademarked name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark. Where such designations appear in this book, they have been printed with initial caps.
McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales promotions, or for use in corporate training programs. To contact a representative please e-mail us at .
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. All other trademarks are the property of their respective owners, and McGraw-Hill makes no claim of ownership by the mention of products that contain these marks.
Screen displays of copyrighted Oracle software programs have been reproduced herein with the permission of Oracle Corporation and/or its affiliates.
Sponsoring Editor
Megg Morin
Editorial Supervisor
Jody McKenzie
Project Managers
Harleen Chopra and Sapna Rastogi
Technical Editor
Danny Coward
Copy Editor
Bart Reed
Proofreader
Lisa McCoy
Indexer
Rebecca Plunkett
Production Supervisor
George Anderson
Composition
Cenveo Publisher Services
Illustration
Cenveo Publisher Services
Art Director, Cover
Jeff Weeks
Cover Designer
Pattie Lee
TERMS OF USE
This is a copyrighted work and The McGraw-Hill Companies, Inc. (McGraw-Hill) and its licensors reserve all rights in and to the work. Use of this work is subject to these terms. Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hills prior consent. You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohibited. Your right to use the work may be terminated if you fail to comply with these terms.
THE WORK IS PROVIDED AS IS. McGRAW-HILL AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. McGraw-Hill and its licensors do not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error free. Neither McGraw-Hill nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting therefrom. McGraw-Hill has no responsibility for the content of any information accessed through the work. Under no circumstances shall McGraw-Hill and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the possibility of such damages. This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or otherwise.
A deep reverence to my beloved late father-in-law
Contents at a Glance
Contents
Foreword
Java has been a part of my career and my life nearly since its beginning. I started using Java 1.0 in 1996, and joined the Java team at Sun later that year. It was a rocky beginning, but something quite special happened: Many brilliant people brought together countless ideas to create a platform that changed how people think about software. Many existing companies adopted Java as a core technology, and many new companies were formed either to add to the Java ecosystem or to leverage it in another arena.
Java isnt just a language. It is a platform that consists of many parts, including the Java language, the Java Virtual Machine (VM) core libraries, and many other components. These components make for a flexible, powerful, and versatile technology that reaches into the most diverse range of applications anywhere.
Java isnt just a platform. It is its own ecosystem. Built on top of the Java platform are IDEs, monitoring and management tools, libraries, application servers, test and debug tools, development tools, and, of course, applications of almost every variety.
Developer usage has grown in the years Ive worked on Java. In the late 1990s, developers were counted in the tens and hundreds of thousands. Today, Oracle reports that over nine million developers use Java. Deployments, including Java ME on consumer devices, measure in the billions.
Next page