Foundations of Java for ABAP Programmers
Total Page:16
File Type:pdf, Size:1020Kb
6250FM.qxd 2/22/06 4:44 PM Page i Foundations of Java for ABAP Programmers Alistair Rooney 6250FM.qxd 2/22/06 4:44 PM Page ii Foundations of Java for ABAP Programmers Copyright © 2006 by Alistair Rooney All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13: 978-1-59059-625-8 ISBN-10: 1-59059-625-0 Library of Congress Cataloging-in-Publication data is available upon request. Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Steve Anglin Technical Reviewers: Gene Ames, Stefan Keuker Editorial Board: Steve Anglin, Dan Appleman, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Hassell, Chris Mills, Dominic Shakeshaft, Jim Sumser Project Manager: Richard Dal Porto Copy Edit Manager: Nicole LeClerc Copy Editor: Andy Carroll Assistant Production Director: Kari Brooks-Copony Production Editor: Janet Vail Compositor: Dina Quan Proofreader: April Eddy Indexer: Toma Mulligan/Book Indexers Artist: April Milne Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit http://www.apress.com. The information in this book is distributed on an “as is” basis, without warranty. Although every precau- tion has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com in the Source Code section. 6250FM.qxd 2/22/06 4:44 PM Page iii To Lisa, Samantha, & Justin. 6250FM.qxd 2/22/06 4:44 PM Page iv Contents at a Glance About the Author . xiii Acknowledgments . xv Introduction . xvii PART 1 ■ ■ ■ Introducing Java ■LESSON 1 Your First Java Program . 3 ■LESSON 2 Object Orientation in a Nutshell . 7 ■LESSON 3 The Primitive Data Types . 13 ■LESSON 4 Comments . 17 ■LESSON 5 Naming Standards and Conventions . 19 ■LESSON 6 The Java Operators . 21 ■LESSON 7 Strings with Java . 29 ■LESSON 8 Control Flow . 35 ■LESSON 9 Jump Statements . 41 ■LESSON 10 Arrays and Collections in Java . 43 ■LESSON 11 Object Orientation in Java . 49 ■LESSON 12 More OO in Java—Interfaces and Abstract Classes . 57 ■LESSON 13 Inner, Nested, and Anonymous Classes . 61 ■LESSON 14 Errors and Exceptions . 65 ■LESSON 15 Threads, Daemons, and Garbage Collection . 71 ■LESSON 16 Basic Swing Using Default Layouts . 79 ■LESSON 17 Event Handling . 83 ■LESSON 18 Layout Managers and Other Components . 87 iv 6250FM.qxd 2/22/06 4:44 PM Page v PART 2 ■ ■ ■ Enterprise Java ■LESSON 19 JDBC Technology . 97 ■LESSON 20 The Java Connector (JCo) . 107 ■LESSON 21 Servlets . 115 ■LESSON 22 JavaServer Pages (JSP) . 133 ■LESSON 23 Extensible Markup Language (XML) . 145 ■LESSON 24 Java Messaging Services . 165 ■LESSON 25 Enterprise JavaBeans 3.0 . 171 ■INDEX . 193 v 6250FM.qxd 2/22/06 4:44 PM Page vi 6250FM.qxd 2/22/06 4:44 PM Page vii Contents About the Author . xiii Acknowledgments . xv Introduction . xvii PART 1 ■ ■ ■ Introducing Java ■LESSON 1 Your First Java Program . 3 Hello World of Abapers . 3 ■LESSON 2 Object Orientation in a Nutshell . 7 The Nutshell—Encapsulation . 7 Inheritance and Polymorphism . 8 The Conceptual Model (A Glimpse of UML) . 10 ■LESSON 3 The Primitive Data Types . 13 Boolean . 13 Byte . 14 Integer . 14 Long . 14 Short . 15 Float . 15 Double . 15 Char . 15 Data Types Summary . 16 ■LESSON 4 Comments . 17 Block Comments . 17 Line Comments . 18 Javadoc Comments . 18 vii 6250FM.qxd 2/22/06 4:44 PM Page viii viii ■CONTENTS ■LESSON 5 Naming Standards and Conventions . 19 Legal and Illegal Names . 19 Java Conventions . 20 ■LESSON 6 The Java Operators . 21 Arithmetic Operators . 21 Relational Operators . 22 Increment Operators . 22 Logical Operators . 23 Bitwise Operators . 24 Block Scope . 26 ■LESSON 7 Strings with Java . 29 Declaring a String . 30 Concatenating Strings . 31 Using the String Methods . ..