ONLINE ACCESS Thank you for purchasing a new copy of Java™ How to Program, Tenth Edition, Early Objects Your textbook includes 12 months of prepaid access to the book’s Companion Website This prepaid subscription provides you with full access to the following student support areas: • VideoNotes (step-by-step video tutorials specifically designed to enhance the programming concepts presented in this textbook) • Source code • Premium web chapters and appendices Additional Comments from Recent Editions Reviewers ❝ Updated to reflect the state of the art in Java technologies; deep and crystal clear explanations The social-consciousness [Making a Difference] exercises are something new and refreshing Nice introduction to Java networking.~—José Antonio González Seco, Parliament of Andalusia ❝An easy-to-read conversational style Clear code examples propel readers to become proficient in Java.~—Patty Kraft, San Diego State U ❝ The [early] introduction of the class concept is clearly presented A comprehensive overview of control structures and the pitfalls that befall new programmers I applaud the authors for their topical research and illustrative examples The arrays exercises are sophisticated and interesting The clearest explanation of pass-by-value and pass-by-reference that I’ve encountered A logical progression of inheritance and the rationale for properly implementing encapsulation in a system involving an inheritance hierarchy The polymorphism and exception handling discussions are the best I’ve seen An excellent strings chapter I like the [recursion] discussions of the ‘Lo Fractal’ and backtracking (which is useful in computer vision applications) A good segue into a data structures course.~—Ric Heishman, George Mason University ❝ Practical top-down, solution approach to teaching programming basics, covering pseudocode, algorithm development and activity diagrams Of immense value to practitioners and students of the object-oriented approach Demystifies inheritance and polymorphism, and illustrates their use in getting elegant, simple and maintainable code The [optional] OO design case study presents the object-oriented approach in a simple manner, from requirements to Java code.~—Vinod Varma, Astro Infotech Private Limited ❝ Easy-to-follow examples provide great teaching opportunities! I like the [optional] graphics track early in the book—the exercises will be fun Use a coin to scratch off the coating and reveal your student access code Do not use a knife or other sharp object as it may damage the code To access the Java How to Program, Tenth Edition, Early Objects Companion Website for the first time, you will need to register online using a computer with an Internet connection and a web browser The process takes just a couple of minutes and only needs to be completed once Go to http://www.pearsonhighered.com/deitel/ Click on Companion Website Click on the Register button On the registration page, enter your student access code* found beneath the scratchoff panel Do not type the dashes You can use lower- or uppercase Follow the on-screen instructions If you need help at any time during the online registration process, simply click the Need Help? icon for the students OO design techniques are incorporated throughout The concept of inheritance is built through examples and is very understandable Great examples of polymorphism and interfaces Great comparison of recursion and iteration The searching and sorting chapter is just right A simplified explanation of Big O—the best I’ve read! I appreciate the coverage of GUI threading issues Great approach to Java web technologies.~ —Sue McFarland Metzger, Villanova University ❝ The Making a Difference exercises are inspired—they have a real contemporary feeling, both in their topics and in the way they encourage the student to gather data from the Internet and bring it back to the question at hand.~—Vince O’Brien, Pearson Education (our publisher) ❝ Most major concepts are illustrated by complete, annotated programs Abundant exercises hone your understanding of the material JDBC is explained well.~—Shyamal Mitra, University of Texas at Austin ❝ The best introductory textbook that I’ve encountered I wish I had this book when I was learning how to program! Good introduction to the software engineering process.~—Lance Andersen, Oracle Corporation ❝ You’ll be well on your way to becoming a great Java programmer with this book.~—Peter Pilgrim, Java Champion, Consultant ❝ A good objects-early introduction to Java Exceptionally well-written recursion chapter Excellent descriptions of the search and sort algorithms and a gentle introduction to Big-O notation—the examples give the code for the algorithms, and output that creates a picture of how the algorithms work.~—Diana Franklin, University of California, Santa Barbara ❝ Suitable for new programmers, intermediate-level programmers who want to hone their skills, and expert programmers who need a well-organized reference Event handling and layouts are well explained.~—Manjeet Rege, Rochester Institute of Technology ❝Beautiful collections of exercises—a nice illustration of how to use Java to generate impressive graphics.~—Amr Sabry, Indiana University Once your personal Login Name and Password are confirmed, you can begin using the Java How to Program, Tenth Edition, Early Objects Companion Website! ❝ The [optional] OOD ATM case study puts many concepts from previous chapters together in a plan for a large program, showing the object-oriented design process—the discussion of inheritance and polymorphism is especially good as the authors integrate these into the design.~ To log in after you have registered: ❝ The transition from design to implementation is explained powerfully—the reader can easily understand the design issues and how to implement them in Java.~—S Sivakumar, Astro Infotech Private Limited You only need to register for this Companion Website once After that, you can log in any time at http://www.pearsonhighered.com/deitel/ by providing your Login Name and Password when prompted *Important: The access code can only be used once This subscription is valid for 12 months upon activation and is not transferable If this access code has already been revealed, it may no longer be valid If this is the case, you can purchase a subscription at http://www.pearsonhighered.com/deitel/, by going to the Java How to Program, Tenth Edition, Early Objects book and following the on-screen instructions —Susan Rodger, Duke University ❝ Comprehensive introduction to Java, now in its eighth major iteration With clear descriptions, useful tips and hints, and well thought out exercises, this is a great book for studying the world’s most popular programming language.~—Simon Ritter, Oracle Corporation ❝ Comprehensive treatment of Java programming, covering both the latest version of the language and Java SE APIs, with its concepts and techniques reinforced by a plethora of well-thought-through exercises.~—Dr Danny Coward, Oracle Corporation ❝ There are many Java programming books in the world This textbook is the best one If you like to introduce object-oriented programming early and smoothly, then this is the right one for you!~—Dr Huiwei Guan, North Shore Community College More Comments on Facing Page Deitel® Series Page How To Program Series Android How to Program, 2/E C++ How to Program, 9/E C How to Program, 7/E Java™ How to Program, 10/E Java™ How to Program, Late Objects Version, 10/E Internet & World Wide Web How to Program, 5/E Visual C++® 2008 How to Program, 2/E Visual Basic® 2012 How to Program, 6/E Visual C#® 2012 How to Program, 5/E Simply Series Simply C++: An App-Driven Tutorial Approach Simply Java™ Programming: An App-Driven Tutorial Approach Simply C#: An App-Driven Tutorial Approach Simply Visual Basic® 2010: An App-Driven Approach, 4/E CourseSmart Web Books www.deitel.com/books/CourseSmart/ C++ How to Program, 8/E and 9/E Simply C++: An App-Driven Tutorial Approach Java™ How to Program, 9/E and 10/E Simply Visual Basic® 2010: An App-Driven Approach, 4/E (continued from previous column) Visual Basic® 2012 How to Program, 6/E Visual Basic® 2010 How to Program, 5/E Visual C#® 2012 How to Program, 5/E Visual C#® 2010 How to Program, 4/E Deitel® Developer Series Android for Programmers: An App-Driven Approach, 2/E, Volume C for Programmers with an Introduction to C11 C++11 for Programmers C# 2012 for Programmers Dive Into® iOS for Programmers: An App-Driven Approach Java™ for Programmers, 3/E JavaScript for Programmers LiveLessons Video Learning Products www.deitel.com/books/LiveLessons/ Android App Development Fundamentals C++ Fundamentals Java™ Fundamentals C# 2012 Fundamentals C# 2010 Fundamentals iOS® App Development Fundamentals JavaScript Fundamentals Visual Basic® Fundamentals To receive updates on Deitel publications, Resource Centers, training courses, partner offers and more, please join the Deitel communities on Facebookđfacebook.com/DeitelFan Twitterđ@deitel Google+google.com/+DeitelFan YouTubeyoutube.com/DeitelTV LinkedInđlinkedin.com/company/deitel-&-associates and register for the free Deitel đ Buzz Online e-mail newsletter at: www.deitel.com/newsletter/subscribe.html To communicate with the authors, send e-mail to: deitel@deitel.com For information on Dive-Into® Series on-site seminars offered by Deitel & Associates, Inc worldwide, write to us at deitel@deitel.com or visit: www.deitel.com/training/ For continuing updates on Pearson/Deitel publications visit: www.deitel.com www.pearsonhighered.com/deitel/ Visit the Deitel Resource Centers that will help you master programming languages, software development, Android and iOS app development, and Internet- and web-related topics: www.deitel.com/ResourceCenters.html Paul Deitel Deitel & Associates, Inc Harvey Deitel Deitel & Associates, Inc Editorial Director, ECS: Marcia Horton Executive Editor: Tracy Johnson (Dunkelberger) Director of Marketing: Christy Lesko Marketing Manager: Yez Alayan Marketing Assistant: Jon Bryant Director of Program Management: Erin Gregg Program Management—Team Lead: Scott Disanno Program Manager: Carole Snyder Project Management-Team Lead: Laura Burgess Project Manager: Robert Engelhardt Procurement Specialist: Linda Sager Cover Design: Paul Deitel, Harvey Deitel, Abbey Deitel, Barbara Deitel, Laura Gardner Permissions Supervisor: Michael Joyce Permissions Administrator: Jenell Forschler Director, Image Asset Services: Annie Atherton Manager, Visual Research: Karen Sanatar Cover Art: © Nikrub/Shutterstock Media Project Manager: Renata Butera Credits and acknowledgments borrowed from other sources and reproduced, with permission, in this textbook appear on page vi The authors and publisher of this book have used their best efforts in preparing this book These efforts include the development, research, and testing of the theories and programs to determine their effectiveness The authors and publisher make no warranty of any kind, expressed or implied, with regard to these programs or to the documentation contained in this book The authors and publisher shall not be liable in any event for incidental or consequential damages in connection with, or arising out of, the furnishing, performance, or use of these programs Copyright © 2015, 2012 and 2009 Pearson Education, Inc All rights reserved Manufactured in the United States of America This publication is protected by Copyright, and permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise To obtain permission(s) to use material from this work, please submit a written request to Pearson Education, Inc., Permissions Department, One Lake Street, Upper Saddle River, New Jersey 07458, or you may fax your request to 201-236-3290 Many of the designations by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed in initial caps or all caps Library of Congress Cataloging-in-Publication Data On file 10 ISBN-10: 0-13-380780-0 ISBN-13: 978-0-13-380780-6 To Brian Goetz, Oracle’s Java Language Architect and Specification Lead for Java SE 8’s Project Lambda: Your mentorship helped us make a better book Thank you for insisting that we get it right Paul and Harvey Deitel Trademarks DEITEL, the double-thumbs-up bug and DIVE INTO are registered trademarks of Deitel and Associates, Inc Oracle and Java are registered trademarks of Oracle and/or its affiliates Other names may be trademarks of their respective owners Microsoft and/or its respective suppliers make no representations about the suitability of the information contained in the documents and related graphics published as part of the services for any purpose All such documents and related graphics are provided “as is” without warranty of any kind Microsoft and/ or its respective suppliers hereby disclaim all warranties and conditions with regard to this information, including all warranties and conditions of merchantability, whether express, implied or statutory, fitness for a particular purpose, title and non-infringement In no event shall Microsoft and/or its respective suppliers be liable for any special, indirect or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract, negligence or other tortious action, arising out of or in connection with the use or performance of information available from the services The documents and related graphics contained herein could include technical inaccuracies or typographical errors Changes are periodically added to the information herein Microsoft and/or its respective suppliers may make improvements and/or changes in the product(s) and/or the program(s) described herein at any time Partial screen shots may be viewed in full within the software version specified Microsoft® and Windows® are registered trademarks of the Microsoft Corporation in the U.S.A and other countries Screen shots and icons reprinted with permission from the Microsoft Corporation This book is not sponsored or endorsed by or affiliated with the Microsoft Corporation.UNIX is a registered trademark of The Open Group Apache is a trademark of The Apache Software Foundation CSS and XML are registered trademarks of the World Wide Web Consortium Firefox is a registered trademark of the Mozilla Foundation Google is a trademark of Google, Inc Mac and OS X are trademarks of Apple Inc., registered in the U.S and other countries Linux is a registered trademark of Linus Torvalds All trademarks are property of their respective owners Throughout this book, trademarks are used Rather than put a trademark symbol in every occurrence of a trademarked name, we state that we are using the names in an editorial fashion only and to the benefit of the trademark owner, with no intention of infringement of the trademark Contents Chapters 26–34 and Appendices F–N are PDF documents posted online at the book’s Companion Website (located at www.pearsonhighered.com/deitel/) See the inside front cover for information on accessing the Companion Website Foreword xxiii Preface xxv Before You Begin xxxix Introduction to Computers, the Internet and Java 1.1 1.2 Introduction Hardware and Software 1.2.1 Moore’s Law 1.2.2 Computer Organization Data Hierarchy Machine Languages, Assembly Languages and High-Level Languages Introduction to Object Technology 1.5.1 The Automobile as an Object 1.5.2 Methods and Classes 1.5.3 Instantiation 1.5.4 Reuse 1.5.5 Messages and Method Calls 1.5.6 Attributes and Instance Variables 1.5.7 Encapsulation and Information Hiding 1.5.8 Inheritance 1.5.9 Interfaces 1.5.10 Object-Oriented Analysis and Design (OOAD) 1.5.11 The UML (Unified Modeling Language) Operating Systems 1.6.1 Windows—A Proprietary Operating System 1.6.2 Linux—An Open-Source Operating System 1.6.3 Android Programming Languages Java A Typical Java Development Environment Test-Driving a Java Application 4 10 10 11 11 11 11 11 12 12 12 12 13 13 13 14 14 15 17 17 21 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 viii 1.11 1.12 1.13 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.1 3.2 Contents Internet and World Wide Web 1.11.1 The Internet: A Network of Networks 1.11.2 The World Wide Web: Making the Internet User-Friendly 1.11.3 Web Services and Mashups 1.11.4 Ajax 1.11.5 The Internet of Things Software Technologies Keeping Up-to-Date with Information Technologies Introduction to Java Applications; Input/Output and Operators Introduction Your First Program in Java: Printing a Line of Text Modifying Your First Java Program Displaying Text with printf Another Application: Adding Integers 2.5.1 import Declarations 2.5.2 Declaring Class Addition 2.5.3 Declaring and Creating a Scanner to Obtain User Input from the Keyboard 2.5.4 Declaring Variables to Store Integers 2.5.5 Prompting the User for Input 2.5.6 Obtaining an int as Input from the User 2.5.7 Prompting for and Inputting a Second int 2.5.8 Using Variables in a Calculation 2.5.9 Displaying the Result of the Calculation 2.5.10 Java API Documentation Memory Concepts Arithmetic Decision Making: Equality and Relational Operators Wrap-Up Introduction to Classes, Objects, Methods and Strings Introduction Instance Variables, set Methods and get Methods 3.2.1 Account Class with an Instance Variable, a set Method and a get Method 3.2.2 AccountTest Class That Creates and Uses an Object of Class Account 3.2.3 Compiling and Executing an App with Multiple Classes 3.2.4 Account UML Class Diagram with an Instance Variable and set and get Methods 3.2.5 Additional Notes on Class AccountTest 25 26 26 26 27 27 28 30 34 35 35 41 43 45 45 46 46 47 48 48 49 49 49 49 50 51 54 58 69 70 71 71 74 77 77 78 Index nested class 316, 488, 929 relationship between an inner class and its top-level class 501 nested control statements 126, 185, 187, 217 Examination-results problem 129 nested for statement 253, 273, 274, 275, 279 enhanced for 274 nested if selection statement 111 nested if else selection statement 107, 109, 111, 113 nested parentheses 52 nesting rule 185 NetBeans Hierarchy window 1114, 1115 Inspector window 1115 JavaFX FXML Application project 1111 Library window 1115, 1116 Projects window 1113 Netbeans 18 demonstration video 35 network message arrival 451 networking package 212 new keyword 47, 75, 246, 247, 1146 New Project dialog (NetBeans) 1112, 1122 new Scanner(System.in) expression 47 new state 961 newCachedThreadPool method of class Executors 965 newCondition method of interface Lock 1003, 1004 newDirectoryStream method of class Files 648 newFactory method of interface RowSetProvider 1080 newline character 42 newline escape sequence, \n 43, 313 newOutputStream method of class Files 665, 668 next method of Iterator 691 of ResultSet 1066 of Scanner 75 nextDouble method of class Scanner 88 nextInt method of class Random 214, 217 nextLine method of class Scanner 75 Nimbus look and feel 476 swing.properties lv, 476 Nimbus look-and-feel 929 no-argument constructor 327, 328 Node class (JavaFX) 1110, 1131 node in a JavaFX application 1110 node in a list 872 non-deterministic random numbers 213 NONE constant of class GridBagConstraints 944 nonfatal logic error 110 nonfatal runtime error 21 nonlinear data structures 872 NORTH constant of class BorderLayout 518, 532 NORTH constant of class GridBagConstraints 943 NORTHEAST constant of class GridBagConstraints 943 NORTHWEST constant of class GridBagConstraints 943 NoSuchElementException class 654, 657 note in the UML 104 Notepad 18 notify method of class Object 988 notify method of Object 388 notifyAll method of class Object 988, 991 notifyAll method of Object 388 now method of class Instant 1026 null 1146 null keyword 76, 81, 91, 246, 478, 871 null reserved word 135 NullPointerException exception 261 Number class 861 doubleValue method 862 number systems 621 NumberFormat class 346, 1026, 1120, 1128 format method 347, 1026 getCurrencyInstance method 347 getPercentInstance method 1026, 1129 setRoundingMode method 1132 numeric Classes 687 O O(1) 815 O(log n) 820 O(n log n) time 833 O(n) time 815 O(n2) time 815 object 2, 10 Object class 338, 361, 365, 670 clone method 388 equals method 387 finalize method 388 getClass method 388, 418, 484 hashCode method 387 notify method 388, 988 notifyAll method 388, 988, 991 toString method 368, 388 wait method 388, 988 object of a derived class 399 object of a derived class is instantiated 387 object-oriented analysis and design (OOAD) 13 object-oriented language 13 object-oriented programming (OOP) 2, 4, 13, 361 object serialization 662 ObjectInput interface 662 readObject method 663 ObjectInputStream class 662, 662, 663, 668 ObjectOutput interface 662 writeObject method 663 ObjectOutputStream class 662, 662, 663, 720 close method 667 ObservableValue interface 1129 ObservableValue interface (JavaFX) addListener method 1132 1187 octal number system (base 8) 241 of method of interface IntStream (Java SE 8) 738 off-by-one error 155 offer method of PriorityQueue 710 OK button 92 ON clause 1057 ONE constant of class BigDecimal 347 ONE constant of class BigInteger 782, 784 one statement per line 57 one-to-many relationship 1051, 1051 one-to-one mapping 714 one-, two- or three-button mouse 521 OOAD (object-oriented analysis and design) 13 OOP (object-oriented programming) 13, 361 opaque Swing GUI components 522 open a file 646 OPEN constant of class Arc2D 585 Open Handset Alliance 14 open source 14 operand 48, 125, 308 operating system 13, 14 operation code 308 operation in the UML 78 operation parameter in the UML 78 operator 48 precedence and associativity chart 134 operator precedence 52, 784 operator precedence chart 125 Operator Precedence Chart Appendix 1143 rules 52 Operators ^, boolean logical exclusive OR 176, 179 , predecrement/postdecrement 131 , prefix decrement/postfix decrement 132 !, logical NOT 176, 179 ?:, ternary conditional operator 110, 134 *=, multiplication assignment operator 131 /=, division assignment operator 131 &, boolean logical AND 176, 178 &&, conditional AND 176, 177 %=, remainder assignment operator 131 ++, prefix increment/postfix increment 132 ++, preincrement/postincrement 131 +=, addition assignment operator 131 = 48, 57 -=, subtraction assignment operator 131 |, boolean logical inclusive OR 176, 178 ||, conditional OR 176, 177 arithmetic 51 binary 48, 51 boolean logical AND, & 176, 178 boolean logical exclusive OR, ^ 176, 179 1188 Index Operators (cont.) boolean logical inclusive OR, | 178 cast 125 compound assignment 131, 133 conditional AND, && 176, 178 conditional operator, ?: 110, 134 conditional OR, || 176, 177, 178 decrement operator, 131, 132 increment and decrement 132 increment, ++ 131 logical complement, ! 179 logical negation, ! 179 logical operators 176, 179, 180 multiplication, * 51 multiplicative: *, / and % 125 postfix decrement 131 postfix increment 131 prefix decrement 131 prefix increment 131 remainder 150 remainder, % 51, 52 subtraction, - 52 optimizing compiler 162 Optional class (Java SE 8) 752 optional package 885 OptionalDouble class (Java SE 8) 739, 757 getAsDouble method 739, 757 orElse method 739, 757 or method of functional interface Predicate (Java SE 8) 745 Oracle Corporation 1046 order 103 ORDER BY SQL clause 1052, 1055, 1056 order in which actions should execute 102 Order of catch Blocks exercise 472 order of exception handlers 472 ordering of records 1052 orElse method of class OptionalDouble (Java SE 8) 739, 757 orientation information origin component 928 out-of-bounds array index 451 outer set of brackets 256 OutOfMemoryError 872 output 39 output cursor 39, 42 output device output parameter for a CallableStatement 1098 output unit OutputStream class 663, 673 OutputStreamWriter class 676 oval 571, 575 oval bounded by a rectangle 575 oval filled with gradually changing colors 584 overflow 451 overflow error 313 overload a method 225 overloaded constructors 324 overloaded method 840 overloading generic methods 848 override a superclass method 364, 368 P PaaS (Platform as a Service) 28 pack method of class Window 936 package 45, 201, 211, 882 package access 344 package-access members of a class 345 package-access methods 344 package declaration 883 package directory names 884 package directory structure 883 package keyword 1146 package name 79 package overview 213 Packages default package 79 java time 321 java.awt 479, 559, 581, 916, 928 java.awt.color 581 java.awt.event 212, 491, 493, 518, 528 java.awt.font 581 java.awt.geom 212, 581 java.awt.image 581 java.awt.image.renderable 581 java.awt.print 581 java.beans 1024 java.io 212, 646 java.lang 48, 203, 212, 365, 387, 597, 963 java.math 126, 346, 781, 1128 java.net 212 java.nio.file 645, 646, 647, 759 java.security 213 java.sql 212, 1063, 1066 java.text 346, 1120, 1128 java.time 213 java.util 46, 212, 288 java.util.concurrent 212, 964, 984, 1009, 1030 java.util.concurrent.locks 1002, 1003 java.util.function (Java SE 8) 732, 738 java.util.prefs 718 java.util.regex 597 java.util.stream (Java SE 8) 736 javafx.application Application 1119 javafx.beans.value 1128, 1132 javafx.event 1129 javafx.fxml 1129 javafx.scene 1110, 1122, 1127 javafx.scene.control 1120, 1129 javafx.scene.layout 1115, 1119 javafx.stage 1110 javax.sql.rowset 1080 javax.swing 212, 474, 476, 484, 495, 540, 563, 916, 929, 935 javax.swing.event 212, 492, 493, 510, 518, 916 javax.swing.table 1068, 1079 packages create your own 882 naming 883 padding (JavaFX) 1125 Padding property of a JavaFX layout container 1125 Page Down key 525 page layout software 597 Page Up key 525 Paint object 584 paintComponent method of class JComponent 522, 556, 913, 915 paintComponent method of JComponent 137 palindrome 150, 807 Palindromes exercise 807 panel 538 parallel 958 parallel operations 958 parallel stream 1029 parallelPrefix method of class Arrays 1027 parallelSetAll method of class Arrays 1027 parallelSort method of class Arrays 287, 1025 parallelSort method of class Arrays (Java SE 8) 745 parameter 76 parameter in the UML 78 parameter list 73 parameter list in a lambda 733 parameterized class 849 parameterized type 849 Parent class (JavaFX) 1122, 1127 parent node 894, 907 parent window 91, 478, 912, 933 parent window for a dialog box 923 parent window specified as null 923 parentheses 38, 52 nested 52 redundant 53 unnecessary 53 parentheses to force order of evaluation 134 parseInt method of class Integer 478 parseInt method of Integer 92, 188, 283 partition step in quicksort 837, 838 Pascal programming language 15 pass an array element to a method 264 pass an array to a method 264 pass-by-reference 265 pass-by-value 263, 265 passing options to a program 283 password 485 PATH environment variable liv, lv, 40 Path interface 647 getFileName method 648 isAbsolute method 648 toAbsolutePath method 648 toString method 648 Paths class 647 get method 647, 648 pattern 581 Pattern class 597, 631 compile method 631 matcher method 631 matches method 631 splitAsStream method (Java SE 8) 760 pattern matching 1053 Index pattern of 1s and 0s Payable interface declaration 424 Payable interface hierarchy UML class diagram 423 Payable interface test program processing Invoices and Employees polymorphically 430 Payroll System Modification exercise 439 peek method of class PriorityQueue 710 peek method of class Stack 710 percent (%) SQL wildcard character 1053 perfect number (exercise) 240 perform a calculation 58 perform a task 73 perform an action 39 performance of binary tree sorting and searching 910 Performance Tips overview xxxviii performing operations concurrently 958 Perl (Practical Extraction and Report Language) 16 persistent persistent data 645 persistent Hashtable 718 phase 120 Phishing Scanner 683 PHP 16, 28 physical input operation 675 physical output operation 674 PI 592 “pick off” each digit 67 pie chart 593 Pie Chart exercise 593 PIE constant of class Arc2D 585 pie-shaped arc 585 Pig Latin 637 pipe 673 PipedInputStream class 673 PipedOutputStream class 673 PipedReader class 676 PipedWriter class 676 pixel (“picture element”) 135, 556 PLAF (pluggable look-and-feel) 912 PLAIN constant of class Font 567 PLAIN_MESSAGE 478 Platform as a Service (PaaS) 28 platform dependency 963 platform independent 19 pluggable look-and-feel (PLAF) 912 pluggable look-and-feel package 480 PNG (Portable Network Graphics) 484 point 567 Point class 523 poker 307 poll method of PriorityQueue 710 polygon 578, 580 Polygon class 556, 578 addPoint method 579, 581 polyline 578 polylines 578 polymorphic processing of collections 688 polymorphic processing of related exceptions 454 polymorphically process Invoices and Employees 430 polymorphism 171, 391, 396 polynomial 53, 54 1189 pop method of Stack 710 previous method of ListIterator pop off a stack 209 pop stack operation 887 popup trigger event 925, 928 portability 558 Portability Tips overview xxxviii portable 19 portable GUI 212 Portable Network Graphics (PNG) 484 position number 245 positive and negative arc angles 576 positive degrees 575 postcondition 465 postdecrement 132 postfix decrement operator 131 postfix expression evaluation algorithm 905 postfix increment operator 131, 157 postfix notation 905 PostgreSQL 1046 postincrement 132, 133 postorder traversal 894, 898 pow method of class BigDecimal 347 pow method of class Math 162, 203, 235 power (exponent) 204, 240 power of larger than 100 114 Practical Extraction and Report Language (Perl) 16 prebuilt data structures 685 precedence 52, 58, 134, 784 arithmetic operators 52 chart 52, 125 precedence chart 134 Precedence Chart Appendix 1143 precise floating-point calculations 346 precision of a formatted floating-point number 88, 126 precondition 465 predecrement 132 predefined character class 624 predicate 741, 1053 Predicate functional interface (Java SE 8) 733, 751 and method 745 negate method 745 or method 745 predicate method 171, 332, 878 preemptive scheduling 963 Pref Height property of a JavaFX component 1116 Pref Width property of a JavaFX component 1116 Pref Width property of a JavaFX control 1124 Preferences API 718 preferred size (JavaFX) 1116 prefix decrement operator 131 prefix increment operator 131 preincrement 132, 133 Preincrementing and postincrementing 132 preorder traversal 894 PreparedStatement interface 1082, 1083, 1085, 1089, 1098 executeQuery method 1089 executeUpdate method 1089 setString method 1082, 1089 prepareStatement method of interface Connection 1089 694 primary key 1047, 1051 composite 1051 primary memory prime 240, 727 prime number 306, 762 primitive type 47, 80, 134, 210 boolean 1154 byte 165 char 47, 165 double 47, 84, 122 float 47, 84 int 47, 122, 131, 165 names are keywords 47 passed by value 266 promotions 211 short 165 principal in an interest calculation 160 Principle of Least Privilege 225 principle of least privilege 343 print a line of text 39 print an array 807 Print an Array Backward exercise 807 Print an Array exercise 807 print an array recursively 807 print debugger command 1153 print method of System.out 42 print on multiple lines 41, 42 print spooling 891, 977 printArray generic method 843 printf method of System.out 43 printing a binary tree in a twodimensional tree format 900 printing trees 909 println method of System.out 39, 42 printStackTrace method of class Throwable 461 PrintStream class 674, 720 PrintWriter class 654, 676 priority of a thread 962 PriorityBlockingQueue class 1010 PriorityQueue class 710 clear method 710 offer method 710 peek method 710 poll method 710 size method 710 private access modifier 72, 321, 364 data 331 field 330 keyword 331, 1146 private static class member 339 probability 214 procedure for solving a problem 102 processing phase 120 processing unit producer 959, 976 producer thread 977 producer/consumer relationship 976, 996 product of odd integer 196 program program construction principles 190 program control 102 program development tool 106, 122 program execution stack 887 program in the general 396, 439 1190 Index program in the specific 396 programmer project (NetBeans) 1112 Projects window in NetBeans 1113 promotion 125 of arguments 210 rules 125, 210 promotions for primitive types 211 prompt 48 Properties class 718 getProperty method 718 keySet method 721 list method 720 load method 721 setProperty method 718 store method 720 propertyChange method of interface PropertyChangeListener 1024 PropertyChangeListener interface 1024 propertyChange method 1024 protected access modifier 321, 364, 1146 protocol for communication (jdbc) 1065 pseudocode 103, 107, 116, 126, 128 algorithm 121 first refinement 120, 127 second refinement 120, 128 public abstract method 421 access modifier 71, 72, 206, 321, 364 final static data 421 interface 316 keyword 37, 72, 1146 member of a subclass 364 method 137, 317, 321 method encapsulated in an object 320 service 316 static class members 339 static method 339 push method of class Stack 709 push onto a stack 209 push stack operation 887 put method of interface BlockingQueue 984, 985 of interface Map 717 Pythagorean Triples 197 Python 16 Q quad-core processor quadratic run time 815 qualified name 1057 quantifiers used in regular expressions 628, 629 quantum 962 query 1046, 1048 query a database 1063 query application for the books database 1104 query method 331 QUESTION_MESSAGE 478 queue 710, 870, 890 Queue interface 686, 710, 984 quicksort algorithm 837 R RadialGradientPaint class 584 radians 204 radio button 495, 501 radio button group 501 radius 592 radius of a circle 239 radix (base) of a number 621 raised rectangle 575 RAM (Random Access Memory) Random Characters exercise 592 Random class 300 nextInt method 214, 217 Random Colors exercise 593 random limericks 637 Random Lines Using Class Line2D.Double exercise 592 random numbers difference between values 218 element of chance 213 generation 257 generation to create sentences 637 scaling 214 scaling factor 214, 217, 218 shift a range 214 shifting value 214, 217, 218 Random Triangles exercise 592 randomly generated triangles 592 randomly sized shapes 593 range checking 119 range method of class EnumSet 337 range method of interface IntStream (Java SE 8) 743 range-view methods 694, 712 rangeClosed method of interface IntStream (Java SE 8) 743 ratio of successive Fibonacci numbers 783 Rational class 357 Rational Numbers (exercise) 357 raw type 857 read-only file 667 read-only text 481 readability 36, 37, 128 Reader class 675 reading files 647 readObject method of ObjectInput 663 readObject method of ObjectInputStream 670 ready state 962 real number 47, 122 real part 356 realization in the UML 423 “receiving” section of the computer reclaim memory 342 record 7, 651 rectangle 356, 556, 560, 572 Rectangle Class (exercise) 356 Rectangle2D class 556 Rectangle2D.Double class 581 recursion overhead 788 quicksort 837 recursion step 778, 784 recursive backtracking 802 recursive binary search algorithm 837 recursive call 778, 784, 785 recursive evaluation 780 Recursive evaluation of 5! 780 recursion (cont.) recursive factorial method 779 recursive linear search algorithm 837 recursive method 777 Recursive power Method exercise 805 recursive step 837 recursively generating Fibonacci numbers 785 Recursively Print a List Backwards 907 Recursively Search a List 907 Recursion Exercises binary search 837 Eight Queens 807 Find the Minimum Value in an Array 807 Fractals 807 Generating Mazes Randomly 809 Greatest Common Divisor 806 linear search 837 Maze Traversal Using Recursive Backtracking 808 Mazes of Any Size 809 Palindromes 807 Print an Array 807 Print an Array Backward 807 quicksort 837 Recursive power Method 805 Time to Calculate Fibonacci Numbers 809 Visualizing Recursion 806 recursive backtracking 809 redirect a standard stream 646 reduce method of interface DoubleStream (Java SE 8) 757 reduce method of interface IntStream (Java SE 8) 739 reduction (mutable) 745 reduction operations 735 redundant parentheses 49, 53 reentrant lock 992 ReentrantLock class 1002, 1004 refactoring 28 refer to an object 81 reference 81 reference type 80, 344 refinement process 120 regexFilter method of class RowFilter 1079 regionMatches method of class String 601 register an ActionListener 924 register event handlers (JavaFX) 1127 registered listener 494 registering the event handler 488, 1121 regular expression 624, 758 ^ 628 ? 628 632 {n,} 629 {n,m} 628 {n} 628 * 628 \D 625 \d 625 \S 625 \s 625 \W 625 Index regular expression (cont.) \w 625 + 628 | 628 reinventing the wheel 11, 45, 285 relational database 1046, 1047 relational database management system (RDBMS) 1046 relational database table 1047 relational operators 54 relationship between an inner class and its top-level class 501 RELATIVE constant of class GridBagConstraints 949 relative path 647 release a lock 968, 990, 991 release a resource 455 release candidate 29 reluctant quantifier 629 remainder 51 remainder compound assignment operator, %= 131 REMAINDER constant of class GridBagConstraints 949 remainder operator, % 51, 52, 150 remove duplicate String 711 remove method of class ArrayList 288, 290 remove method of interface Iterator 691 removeTableModelListener method of interface TableModel 1068 repaint method of class Component 524 repaint method of class JComponent 559 repetition 105, 186 counter controlled 116, 124, 127, 128 definite 115 sentinel controlled 119, 121, 122, 124 repetition statement 104, 105, 113, 121, 787 while 105, 163, 164, 186, 164, 186 for 105, 158, 186 while 105, 114, 117, 122, 124, 153, 186, 187 repetition terminates 114 replaceAll method of class Matcher 631 of class String 629 replaceFirst method of class Matcher 631 of class String 629 requestFocus method 1131 requestFocus method of class Node 1131 requirements 13 requirements of an app 171 reservations system 301 reserved word 37, 105, 1146 false 106 null 76, 81, 135 true 106 resizable array implementation of a List 688 resolution 135, 556 resource leak 337, 454 resource-release code 455 responses to a survey 254 result 1053 result set concurrency 1072 result set type 1072 ResultSet interface 1066, 1072, 1073, 1074 absolute method 1073 close method 1067 column name 1067 column number 1067 CONCUR_READ_ONLY constant 1072 CONCUR_UPDATABLE constant 1072 concurrency constant 1072 getInt method 1067 getObject method 1067, 1073 getRow method 1074 last method 1074 next method 1066 TYPE_FORWARD_ONLY constant 1072 TYPE_SCROLL_INSENSITIVE constant 1072 TYPE_SCROLL_SENSITIVE constant 1072 ResultSetMetaData interface 1066, 1073 getColumnClassName method 1073 getColumnCount method 1066, 1073 getColumnName method 1073 getColumnType method 1066 ResultSetTableModel enables a JTable to display the contents of a ResultSet 1068 resumption model of exception handling 449 rethrow an exception 458, 472 Rethrowing Exceptions exercise 472 return keyword 74, 202, 209, 1146 return statement 778 return type of a method 73 reusability 849, 870 reusable software components 10, 211, 362 reuse 11, 45 reverse method of class StringBuilder 614 reverse method of Collections 696, 702 reversed method of interface Comparator (Java SE 8) 748 reverseOrder method of Collections 698 RGB value 559, 560, 565 RGB values 227 right aligned 530 right brace, } 38, 46, 117, 124 right child 893 RIGHT constant of class FlowLayout 532 right justify output 161 right subtree 898, 908 right-align the contents of a column 1124 rigid area of class Box 942 rise-and-shine algorithm 102 1191 Ritchie, Dennis 16 robust 48 robust application 442 roll back a transaction 1099 rollback method of interface Connection 1099 rolling two dice 220 rollover Icon 497 root directory 647 root node 893, 1110 rotate method of class Graphics2D 588 round a floating-point number for display purposes 126 round-robin scheduling 962 rounded rectangle 573, 585 rounding a number 51, 118, 163, 204, 238 RoundingMode enum 348, 1128 RoundRectangle2D class 556 RoundRectangle2D.Double class 581, 585 row 1047, 1051, 1052, 1053, 1054, 1058 RowFilter class 1079 rows of a two-dimensional array 272 rows to be retrieved 1052 RowSet interface 1080 RowSetFactory class 1080 RowSetFactory interface createJdbcRowSet method 1080 RowSetProvider class 1080 RowSetProvider interface newFactory method 1080 Ruby on Rails 17 Ruby programming language 17 Rule of Entity Integrity 1051 Rule of Referential Integrity 1050 rule of thumb (heuristic) 176 rules for forming structured programs 182 rules of operator precedence 52, 784 run debugger command 1151 run method of interface Runnable 963 runAsync method of class CompletableFuture 1034 Runnable interface 432, 963 run method 963 runnable state 961 running an application 21 running state 962 running total 120 runtime error 21 runtime logic error 48 RuntimeException class 452 S SaaS (Software as a Service) 28 Safari 90 SalariedEmployee class that implements interface Payable method getPaymentAmount 428 SalariedEmployee concrete class extends abstract class Employee 408 Sales Commissions 300 SAM interface 732 SansSerif Java font 567 saturation 565 1192 Index savings account 160 SavingsAccount Class (exercise) 356 scalar 263 scaling (random numbers) 214 scale factor 214, 217, 218 scaling BigDecimal values 348 Scanner class 46, 47 hasNext method 168 next method 75 nextDouble method 88 nextLine method 75 scanning images Scene Builder 1109, 1111 Scene class (JavaFX) 1110, 1119, 1127, 1128 scene graph 1128 scene graph in a JavaFX application 1110 scene in a JavaFX application 1110 scheduling threads 962 scope 157 scope of a declaration 222 scope of a type parameter 851 scope of a variable 157 Scrapbooking app exercise 1139 screen 4, screen cursor 43 screen-manager program 398 Screen Saver exercise 592 Screen Saver for Random Number of Lines exercise 593 Screen Saver Using the Java2D API exercise 593 Screen Saver Using Timer exercise 592 Screen Saver with Shapes exercise 593 scroll 506, 510 scroll arrow 507 scroll box 507 SCROLL_TAB_LAYOUT constant of class JTabbedPane 942 scrollbar 510, 542 of a JComboBox 507 scrollbar policies 542 SDK (Software Development Kit) 29 search algorithms binary search 816 linear search 812 recursive binary search 837 recursive linear search 837 search key 811 searching 870 searching data 811 second-degree polynomial 53, 54 second refinement 128 second refinement in top-down, stepwise refinement 120 secondary storage secondary storage devices 645 secondary storage unit sector 576 SecureRandom class 213, 214 documentation 214 doubles method (Java SE 8) 762 ints method (Java SE 8) 762 longs method (Java SE 8) 762 streams of random numbers (Java SE 8) 762 security 20 security breach 37, 76 security breaches 213 SecurityException class 653 seful 647 SELECT SQL keyword 1052, 1053, 1054, 1055, 1056 selectAll method 1131 selectAll method of class TextInputControl 1131 selected text in a JTextArea 541 selecting an item from a menu 485, 1121 Selecting Shapes exercise 593 selection 105, 185, 186 selection criteria 1053 selection mode 510 selection sort algorithm 821, 824 selection statement 103, 105 if 105, 106, 165, 186, 187 if else 105, 106, 107, 122, 165, 186 switch 105, 165, 169, 186 self-documenting 48 self-documenting code 48 self-referential class 871, 872 self-similar property 791 semicolon (;) 39, 47, 57 send a message to an object 11 sentence-style capitalization 477 sentinel-controlled repetition 119, 121, 122, 124, 197, 310 sentinel value 119, 121, 124 separator character 650 separator line in a menu 923, 924 sequence 105, 184, 186, 688, 893 sequence structure 103 sequence-structure activity diagram 104 SequenceInputStream class 675 sequential-access file 645, 651 sequential execution 103 Sequentially searching an array for an item 813 Serializable interface 432, 663 serialized object 662 Serif Java font 567 service of a class 321 set debugger command 1153 Set interface 686, 711, 712, 714 stream method (Java SE 8) 760 set method of interface ListIterator 694 set method 324 Set of Integers (exercise) 357 Set of recursive calls for fibonacci( ) 785 SET SQL clause 1059 set-theoretic intersection 357 set-theoretic union 357 set up event handling 488 setAlignment method of class FlowLayout 532 setAutoCommit method of interface Connection 1099 setBackground method of class Component 291, 511, 565 setBounds method of class Component 529 setCharAt method of class StringBuilder 614 setColor method of class Graphics 560, 585 setColor method of Graphics 228 setCommand method of JdbcRowSet interface 1082 setConstraints method of class GridBagLayout 949 setDefaultCloseOperation method of class JFrame 138, 485, 916 setDisabledTextColor method of class JTextComponent 528 setEditable method of class JTextComponent 488 setErr method of class System 646 setFileSelectionMode method of class JFileChooser 670 setFixedCellHeight method of class JList 513 setFixedCellWidth method of class JList 513 setFont method of class Component 500 setFont method of class Graphics 567 setForeground method of class JComponent 924 setHorizontalAlignment method of class JLabel 484 setHorizontalScrollBarPolicy method of class JScrollPane 542 setHorizontalTextPosition method of class JLabel 484 setIcon method of class JLabel 484 setIn method of class System 646 setInverted method of class JSlider 913 setJMenuBar method of class JFrame 917, 924 setLayout method of class Container 483, 530, 534, 537, 942 setLength method of class StringBuilder 613 setLineWrap method of class JTextArea 542 setListData method of class JList 513 setLocation method of class Component 529, 917 setLookAndFeel method of class UIManager 932 setMajorTickSpacing method of class JSlider 916 setMaximumRowCount method of class JComboBox 507 setMnemonic method of class AbstractButton 923 setOpaque method of class JComponent 522, 524 setOut method of System 646 setPaint method of class Graphics2D 584 setPaintTicks method of class JSlider 916 setPassword method of JdbcRowSet interface 1082 setProperty method of Properties 718 setRolloverIcon method of class AbstractButton 498 setRoundingMode method of class NumberFormat 1132 setRowFilter method of class JTable 1079 Index setRowSorter method of class JTable 1079 setScale method of class BigDecimal 348 setSelected method of class AbstractButton 924 setSelectionMode method of class JList 510 setSize method of class Component 529, 917 setSize method of class JFrame 138, 485 setString method of interface PreparedStatement 1082, 1089 setStroke method of class Graphics2D 584 setText method 1131 setText method of class JLabel 390, 484 setText method of class JTextComponent 541 setText method of class TextInputControl 1131 Setting the PATH environment variable liv, lv setToolTipText method of class JComponent 483 setUrl method of JdbcRowSet interface 1080 setUsername method of JdbcRowSet interface 1082 setVerticalAlignment method of class JLabel 484 setVerticalScrollBarPolicy method of class JScrollPane 542 setVerticalTextPosition method of class JLabel 484 setVisible method of class Component 485, 534, 917 setVisible method of class JFrame 138 setVisibleRowCount method of class JList 510 shadow 73 shadow a field 223 shallow copy 388 shape 581 Shape class hierarchy 363, 393 Shape Hierarchy exercise 439 Shape object 584 share memory 959 shared buffer 977 shell 39 shell in Linux 18 shell script 653 Shift 528 shift (random numbers) 214 shifting value 214, 217, 218 “shipping” section of the computer shopping list 113 short-circuit evaluation 178 Short class 687 short primitive type 165, 1146, 1147 promotions 211 short-circuting terminal operation (Java SE 8) 752 shortcut key 918 show method of class JPopupMenu 928 showDialog method of class JColorChooser 564 showInputDialog method of class JOptionPane 92, 477 showMessageDialog method of class JOptionPane 91, 478 showOpenDialog method of class JFileChooser 670 shuffle 257 algorithm 700 shuffle method of class Collections 696, 700, 702 shutdown method of class ExecutorService 967 sibling nodes 893 side effect 178 Sieve of Eratosthenes 306, 762, 1020 signal method of interface Condition 1003, 1007 signal value 119 signalAll method of interface Condition 1003 signature of a method 226, 227 simple condition 176 simple name 884 simplest activity diagram 182, 184 Simpletron Machine Language (SML) 308, 870 Simpletron simulator 310, 313, 871 simulate a middle-mouse-button click on a one- or two-button mouse 521 simulate a right-mouse-button click on a one-button mouse 521 simulation 213 coin tossing 241 Simulation: Tortoise and the Hare 306, 593 simulator 308 sin method of class Math 204 sine 204 single abstract method (SAM) interface 732 single entry point 182 single-entry/single-exit control statements 105, 182 single exit point 182 single inheritance 361 single-line (end-of-line) comment 39 single-precision floating-point number 84 single-quote character 597, 1054 single-selection list 508 single-selection statement 105, 106, 186 single static import 342 single-type-import declaration 885 SINGLE_INTERVAL_SELECTION constant of interface ListSelectionModel 510, 511, 513 SINGLE_SELECTION constant of interface ListSelectionModel 510 single-selection statement if 106 singly linked list 872 size method of class ArrayBlockingQueue 986 of class ArrayList 290 of class PriorityQueue 710 of interface List 690, 694 of interface Map 718 1193 size method of class Files 648 size of a variable 50 skinning 1109 sleep interval 961 sleep method of class Thread 965, 978, 980, 981 sleeping thread 961 Slider class (JavaFX) 1118, 1120 Max property 1126 Value property 1126 valueProperty method 1132 small circles in the UML 104 smallest of several integers 196 smartphone SML 870 SMS Language 643 snap-to ticks for JSlider 912 software Software as a Service (SaaS) 28 Software Development Kit (SDK) 29 software engineering 331 Software Engineering Observations overview xxxviii software model 310 software reuse 11, 202, 882 software simulation 308 solid circle in the UML 104 solid circle surrounded by a hollow circle in the UML 104 Solves Towers of Hanoi problem with a recursive method 790 sort algorithms bubble sort 836 bucket sort 836 insertion sort 824 merge sort 827 quicksort 837 selection sort 821 sort key 811 sort method of class Arrays 285, 817 of class Collections 697 sort method of class Arrays 745, 1025 sorted array 872 sorted method of interface IntStream (Java SE 8) 741 sorted method of interface Stream (Java SE 8) 745, 748 sorted order 712, 714 SortedMap interface 714 SortedSet interface 712, 713 first method 713 last method 713 sorting 870 descending order 697 with a Comparator 698 sorting data 811, 820 Sorting Letters and Removing Duplicates exercise 775 source code 18 SourceForge 14 SOUTH constant of class BorderLayout 518, 532 SOUTH constant of class GridBagConstraints 943 SOUTHEAST constant of class GridBagConstraints 943 SOUTHWEST constant of class GridBagConstraints 943 1194 Index space character 37 Spam Scanner 642 speaking to a computer special character 47, 597 Special Section: Advanced StringManipulation Exercises 638 Special Section: Building Your Own Compiler 870 Special Section: Building Your Own Computer 308 Special Section: Challenging StringManipulation Projects 641 special symbol specialization 361 specifics 398 Spelling Checker project 641 sphere 235 spiral 593, 783 split method of class String 623, 629 split the array in merge sort 827 splitAsStream method of class Pattern (Java SE 8) 760 spooler 891 spooling 891 SQL 1046, 1048, 1052, 1058 DELETE statement 1052, 1060 FROM clause 1052 GROUP BY 1052 IDENTITY keyword 1048 INNER JOIN clause 1052, 1057 INSERT statement 1052, 1058 LIKE clause 1054 ON clause 1057 ORDER BY clause 1052, 1055, 1056 SELECT query 1052, 1053, 1054, 1055, 1056 SET clause 1059 UPDATE statement 1052 VALUES clause 1058 WHERE clause 1053 SQL (Structured Query Language) 1082 SQL injection attack (preventing) 1083 SQL keyword 1052 SQL statement 1099 SQLException class 1065, 1067, 1083 SQLFeatureNotSupportedException class 1073 sqrt method of class Math 203, 204, 210 square brackets, [] 245 square root 204 stack 209, 849, 870, 886 method call stack 210 stack overflow 210 Stack class 710, 886 isEmpty method 710 of package java.util 708 peek method 710 pop method 710 push method 709 stack frame 210, 788 Stack generic class 849 Stack< Double > 856 Stack< Integer > 856 Stack generic class declaration 850 stack operation pop 887 push 887 stack trace 444 stack unwinding 459 stacked building blocks 186 stacking control statements 187 stacking rule 184 StackTraceElement class 461 getClassName method 461 getFileName method 461 getLineNumber method 461 getMethodName method 461 Stage class (JavaFX) 1110, 1119, 1127, 1128 stage in a JavaFX application 1110 stale value 974 standard error stream 448, 457 standard error stream (System.err) 646, 674 standard input stream (System.in) 47, 646 standard output stream 457 standard output stream (System.out) 39, 646, 674 standard reusable component 362 standard time format 319 “warehouse” section of the computer start method of class Application (JavaFX) 1119, 1127 starting angle 575 startsWith method of class String 604 starvation 963 state button 498 state dependent 977 stateChanged method of interface ChangeListener 916 stateful intermediate operation 742 stateless intermediate operation 742 stateless stream operation 742 statement 39, 73 statement block in a lambda 733 Statement interface 1066, 1067, 1082 close method 1067 executeQuery method 1066 Statements 121 break 168, 174, 198 continue 174, 198 control statement 102, 103, 105, 106 control-statement nesting 105 control-statement stacking 105 while 105, 163, 164, 186 double selection 105, 128 empty 57, 110 empty statement 110 enhanced for 262 for 105, 155, 158, 160, 162, 186 if 54, 105, 106, 165, 186, 187 if else 105, 106, 107, 122, 165, 186 looping 105 multiple selection 105 nested 126 nested if else 107, 109 repetition 104, 105, 113 return 202, 209 selection 103, 105 single selection 105 switch 105, 165, 169, 186 switch multiple-selection statement 217 throw 318 Statements (cont.) try 256 try-with-resources 467 while 105, 114, 117, 122, 124, 153, 186, 187 static class member 338, 339 class variable 339 field (class variable) 338 import 342 import on demand 342 keyword 203, 1146 method 79, 91, 162 static binding 420 static interface methods (Java SE 8) 433 static method in an interface (Java SE 8) 732, 763 static method of an interface (Java SE 8) 731 step debugger command 1156 step up debugger command 1156 stop debugger command 1151 store method of Properties 720 stored procedure 1098 straight-line form 51 stream 457 stream (Java SE 8) DoubleStream interface 736 eager operations 739 filter elements 741 intermediate operation 734 IntStream interface 736 lazy operation 741, 742 LongStream interface 736 map elements to new values 742 pipeline 734, 741, 742 terminal operation 734 Stream interface (Java SE 8) 734, 744 collect method 745, 745, 755, 756, 762 distinct method 754 filter method 745, 748 findFirst method 752 forEach method 745 map method 747, 747 sorted method 745, 748 Stream interface (java SE 8) flatMap method 760 stream method of class Arrays (Java SE 8) 743, 744 stream method of interface Set 760 stream of bytes 645 stream pipeline 738 streaming 959 streams 734 streams (Java SE 8) infinite streams 762 strictfp keyword 1146 strictly self-similar fractal 791 string 39 literal 39 of characters 39 String class 597 charAt method 599, 614 compareTo method 601, 603 concat method 608 endsWith method 604 equals method 601, 603 Index String class (cont.) equalsIgnoreCase method 601, 603 format method 92, 318 getChars method 599 immutable 341 indexOf method 605 lastIndexOf method 605 length method 599 matches method 624 regionMatches method 601 replaceAll method 629 replaceFirst method 629 split method 623, 629 startsWith method 604 substring method 607 toCharArray method 610, 807 toLowerCase 694 toLowerCase method 610 toUpperCase 694 toUpperCase method 609 trim method 610 valueOf method 610 String class searching methods 605 string concatenation 208, 341 string literal 597 StringBuffer class 612 StringBuilder class 597, 611 append method 615 capacity method 612 charAt method 614 constructors 612 delete method 617 deleteCharAt method 617 ensureCapacity method 613 getChars method 614 insert method 617 length method 612 reverse method 614 setCharAt method 614 setLength method 613 StringIndexOutOfBoundsExceptio n class 607 StringReader class 676 StringWriter class 676 Stroke object 584, 585 strongly typed languages 134 Stroustrup, Bjarne 442 structured programming 4, 103, 153, 176, 182 summary 182 Structured Query Language (SQL) 1046, 1048, 1052 Student Poll exercise 683 subclass 12, 137, 361 sublist 694 subList method of List 694 submenu 918 submit method of class ExecutorService 1030 subprotocol for communication 1065 subscript (index) 245 substring method of class String 607 subtract method of class BigInteger 782, 784 subtraction 6, 51 operator, - 52 subtraction compound assignment operator, -= 131 suffix F for float literals 710 suffix L for long literals 709 sum method of interface DoubleStream (Java SE 8) 757 sum method of interface IntStream (Java SE 8) 739 sum the elements of an array 251 summarizing responses to a survey 254 super keyword 364, 387, 1146 call superclass constructor 378 super.paintComponent(g) 137 superclass 12, 137, 361 constructor 368 constructor call syntax 378 default constructor 368 direct 361, 363 indirect 361, 363 method overridden in a subclass 386 Supermarket Simulation 906 Supplier functional interface (Java SE 8) 733 Supplier interface (Java SE 8) 1030, 1033 supplyAsync method of class CompletableFuture 1033 swapping values 821, 824 sweep 292, 575 sweep counterclockwise 575 Swing Event Package 212 Swing GUI APIs 475 Swing GUI components 474 Swing GUI components package 212 swing.properties file lv, 476 SwingConstants interface 484, 916 SwingUtilities class 932 updateComponentTreeUI method 932 SwingWorker class 1011 cancel method 1025 doInBackground method 1011, 1014 done method 1011, 1014 execute method 1011 get method 1011 isCancelled method 1020 process method 1012, 1021 publish method 1011, 1021 setProgress method 1012, 1020 switch logic 171 switch multiple-selection statement 105, 165, 169, 186, 217, 1146 activity diagram with break statements 170 case label 168, 169 controlling expression 168 default case 168, 170, 217 Sybase 1046 synchronization 968, 988 synchronization wrapper 721 synchronize 959 synchronize access to a collection 688 synchronized keyword 721, 968, 1146 method 969 statement 968 synchronized collection 688 synchronous error 451 SynchronousQueue class 1010 syntax error 36 1195 System class arraycopy 285, 286 currentTimeMillis method 809 exit method 455, 653 setErr method 646 setIn method 646 setOut 646 System.err (standard error stream) 448, 646, 674 System.in (standard input stream) 646 System.out print method 42, 42 printf method 43 println method 39, 39, 42 System.out (standard output stream) 39, 646, 674 SystemColor class 584 T tab character, \t 43 Tab key 38 tab stops 43 table 272, 1047 table element 272 table of values 272 TableModel interface 1067 addTableModelListener 1068 getColumnClass method 1068, 1073 getColumnCount method 1068, 1073 getColumnName method 1068, 1073 getRowCount method 1068 getValueAt method 1068 removeTableModelListener 1068 TableModelEvent class 1079 TableRowSorter class 1079 tabular format 249 tagging interface 422, 663 tail of a queue 870, 890 tailSet method of class TreeSet 713 take method of class BlockingQueue 984, 986 tan method of class Math 204 tangent 204 target type of a lambda (Java SE 8) 738 Target-Heart-Rate Calculator app exercise 1140 Target-Heart-Rate Calculator exercise 99 Tax Plan Alternatives exercise 199 TCP (Transmission Control Protocol) 25 TCP/IP 26 technical publications 30 Telephone-Number Word Generator exercise 682 temporary 125 TEN constant of class BigDecimal 347 terabyte Terminal application (OS X) 18 terminal operation 738 eager 741 terminal operations mutable reduction 735 reduction 735 1196 Index terminal stream operations (Java SE 8) 734, 745 average method of interface IntStream 739 collect method of interface Stream 745, 755, 756, 762 count method of interface IntStream 739 findFirst method of interface Stream 752 mapToDouble method of interface Stream 756 max method of interface IntStream 739 method of interface IntStream 739 reduce method of interface IntStream 739 short-circuting 752 sum method of interface IntStream 739 terminal window 39 terminate a loop 121 terminate an application 923 terminate successfully 653 terminated state 961 termination housekeeping 338, 388 termination model of exception handling 449 termination phase 120 termination test 787 ternary operator 110 test method of functional interface IntPredicate (Java SE 8) 741, 742 Text analysis 638 text editor 39, 597 text field 92 text file 646 Text property of a Label (JavaFX) 1116 TextEdit 18 TextField class (JavaFX) 1120, 1124 TextInputControl class (JavaFX) 1131 TexturePaint class 556, 584, 585 The “FairTax” 199 thenComparing method of functional interface Comparator (Java SE 8) 753 thick lines 581 this keyword 73, 322, 339, 1146 reference 322 to call another constructor of the same class 327 thread 449, 558 life cycle 960, 962 of execution 959 scheduling 962, 981 state 960 synchronization 721, 968 Thread class currentThread method 965, 970 interrupt method 965 sleep method 965 thread confinement 1011 thread-life-cycle statechart diagram 960, 962 thread pool 963 thread priority 962 thread safe 974, 1011 thread scheduler 962 thread states blocked 961, 969 dead 961 new 961 ready 962 runnable 961 running 962 terminated 961 timed waiting 961 waiting 961 three-button mouse 521 three-dimensional rectangle 572 ThreeDimensionalShape class 393 throw an exception 256, 443, 447 throw an exception 318, 328 throw keyword 458, 1146 throw point 445 throw statement 457 Throwable class 451, 461 getMessage method 461 getStackTrace method 461 hierarchy 452 printStackTrace method 461 throws clause 450 throws keyword 1146 thumb of class JSlider 912, 916 thumb position of class JSlider 916 tick marks on a JSlider 912 TicTacToe 358 exercise 358 tightly packed binary tree 900 Time to Calculate Fibonacci Numbers exercise 809 timed waiting state 961 Timer class 592 timeslice 962 timeslicing 962 title bar 475, 481, 916 title bar of a window 478 title bar of internal window 936 titles table of books database 1048, 1049 toAbsolutePath method of interface Path 648 toArray method of List 695, 696 toCharArray method of class String 610 toCharArray method of String 807 ToDoubleFunction functional interface (Java SE 8) 757 applyAsDouble method 757 toggle buttons 495 token of a String 623 tokenization 623 toList method of class Collectors (Java SE 8) 745 toLowerCase method of class Character 621 toLowerCase method of class String 610, 694 toMillis method of class Duration 1026 tool tips 480, 483, 485 top 120, 710 TOP constant of class JTabbedPane 942 top-down, stepwise refinement 120, 121, 122, 127, 128 top-level class 488 top of a stack 870 toPath method of class File 671 Tortoise and the Hare 306, 593 Tortoise and the Hare exercise 593 toString method of class ArrayList 697, 862 of class Arrays 631, 814 of class Object 368, 388 toString method of an object 208 toString method of interface Path 648 total 115, 120 Total Sales 301 toUpperCase method of class Character 620 toUpperCase method of class String 609, 694 Towers of Hanoi 789 Towers of Hanoi for the case with four disks 789 track mouse events 515 traditional comment 36 trailing white-space characters 610 transaction file 681 transaction processing 1098, 1099 transaction record 682 transfer of control 103, 310, 311, 312 transient keyword 665, 1146 transition arrow 107, 115 in the UML 104 transition arrow in the UML 114 transition in the UML 104 translate method of class Graphics2D 588 translation translator program Transmission Control Protocol (TCP) 25 transparency of a JComponent 522 traverse a tree 898 traverse an array 273 tree 711, 893 TreeMap class 714, 760 TreeSet class 711, 712, 713 headSet method 712 tailSet method 713 trigger an event 479 trigonometric cosine 204 trigonometric sine 204 trigonometric tangent 204 trim method of class String 610 trimToSize method of class ArrayList 288 true 54, 1146 true reserved word 106, 110 truncate 51 truncate fractional part of a calculation 118 truncated 651 truth table 177 truth tables for operator ^ 179 for operator ! 179 for operator && 177 for operator || 177 try block 256, 447, 459 terminates 449 try keyword 447, 1146 try statement 256, 450 try-with-resources statement 467 Turtle Graphics 302, 593 Turtle Graphics exercise 593 Index 24-hour clock format 316 two-dimensional array representation of a maze 808 272, 273 two-dimensional data structure 893 two-dimensional graphics 581 two-dimensional shapes 556 two largest values 148 TwoDimensionalShape class 393 type 46 type argument 851 type casting 125 type-import-on-demand declaration 885 type inference with the notation (Java SE 7) 691 type inferencing 691 type of a lambda expression 733 type of a variable 50 type parameter 843, 849, 856 scope 851 section 843, 849 type safety 842 type variable 843 type-wrapper class 618, 687, 845 implements Comparable 845 TYPE_FORWARD_ONLY constant 1072 TYPE_INT_RGB constant of class BufferedImage 585 TYPE_SCROLL_INSENSITIVE constant 1072 TYPE_SCROLL_SENSITIVE constant 1072 Types class 1067 typesetting system 597 type-wrapper classes 618 typing in a text field 485, 1121 Typing Tutor: Tuning a Crucial Skill in the Computer Age 554 U UIManager class 929 getInstalledLookAndFeels method 929 LookAndFeelInfo nested class 929 setLookAndFeel method 932 UIManager.LookAndFeelInfo class getClassName method 932 UML (Unified Modeling Language) 13 activity diagram 104, 107, 114, 158, 164 arrow 104 class diagram 77 compartment in a class diagram 77 diamond 106 dotted line 105 final state 104 guard condition 106 merge symbol 114 note 104 solid circle 104 solid circle surrounded by a hollow circle 104 UML 105 unary operator 125, 179 cast 125 UnaryOperator functional interface (Java SE 8) 733 unbiased shuffling algorithm 260 unboxing 849, 854 unboxing conversion 687 uncaught exception 449 unchecked exceptions 452 uncovering a component 558 underlying data structure 710 underscore (_) SQL wildcard character 1053, 1054 uneditable JTextArea 539 uneditable text or icons 479 Unicode character set 7, 66, 135, 170, 597, 602, 620, 1147 Unicode value of the character typed 528 Unified Modeling Language (UML) 13 Uniform Resource Identifier (URI) 648 Uniform Resource Locator (URL) 648 union of two sets 357 universal-time format 316, 318, 319 UNIX 39, 168, 653 unlock method of interface Lock 1002, 1007 unmodifiable collection 688 unmodifiable wrapper 721 unnecessary parentheses 53 unspecified number of arguments 281 UnsupportedOperationException class 694 unwatch debugger command 1159 unwinding the method-call stack 459 UPDATE SQL statement 1052, 1059 updateComponentTreeUI method of class SwingUtilities 932 upper bound 846 of a wildcard 862 upper bound of a type parameter 847, 848 upper-left corner of a GUI component 135, 556 upper-left x-coordinate 560 upper-left y-coordinate 560 uppercase letter 38, 47 URI (Uniform Resource Identifier) 648 URL (Uniform Resource Locator) 648 Use binary search to locate an item in an array 817 Utilities Package 212 utility method 319 V va 654 valid identifier 47 validate data 119 validate method of class Container 537 validity checking 331 value of a variable 50 Value property of a Slider (JavaFX) 1126 value to the nearest integer 238 valueChanged method of interface ListSelectionListener 510 valueOf method of class BigDecimal 347 valueOf method of class String 610 valueProperty method of class Slider 1132 values method of an enum 336 VALUES SQL clause 1058, 1058 1197 van Rossum, Guido 16 variable 45, 46, 47 name 46, 50 reference type 80 size 50 type 50 value 50 variable declaration statement 47 variable is not modifiable 343 variable-length argument list 281 variable names came case naming 72 variable scope 157 VBox class (JavaFX) 1115 alignment 1116 Alignment property 1116 Vbox class (JavaFX) 1115 Vector class 688 VERTICAL constant of class GridBagConstraints 944 vertical coordinate 135, 556 vertical gap space 534 vertical scrolling 541 vertical strut 941 VERTICAL_SCROLLBAR_ALWAYS constant of class JScrollPane 542 VERTICAL_SCROLLBAR_AS_NEEDED constant of class JScrollPane 542 VERTICAL_SCROLLBAR_NEVER constant of class JScrollPane 542 Vgap property of a GridPane 1125 vi editor 18 video game 214 video streaming 995 View 475 view (in MVC) 1121 virtual key code 528 virtual machine (VM) 19 Visual Basic programming language 16 Visual C# programming language 16 Visual C++ programming language 16 visual feedback 498 visual programming 1111 Visualizing Recursion exercise 806 void keyword 38, 73, 1146 volatile information volatile keyword 1146 volume of a sphere 235, 237 W W3C (World Wide Web Consortium) 26 wait method of class Object 388, 988 waiting line 710 waiting state 961 waiting thread 991 watch debugger command 1158 web browser 90 web page 90 web services 26 Amazon eCommerce 27 eBay 27 Facebook 27 Flickr 27 Foursquare 27 Google Maps 26 Groupon 27 Instagram 27 1198 Index web services (cont.) Last.fm 27 LinkedIn 27 Microsoft Bing 27 Netflix 27 PayPal 27 Salesforce.com 27 Skype 27 Twitter 26 WeatherBug 27 Wikipedia 27 Yahoo Search 27 YouTube 27 Zillow 27 weightx field of class GridBagConstraints 944 weighty field of class GridBagConstraints 944 WEST constant of class BorderLayout 518, 532 WEST constant of class GridBagConstraints 943 WHERE SQL clause 1052, 1053, 1054, 1056, 1059, 1060 while repetition statement 105, 114, 117, 122, 124, 153, 186, 187, 1146 activity diagram in the UML 114 white space 37, 39, 58 white-space character 610, 623, 624 widgets 474, 1108 width 571 width of a rectangle in pixels 560 wildcard 862 in a generic type parameter 860 type argument 862, 862 upper bound 862 window 90, 135, 136, 138, 916 Window class 916, 917 addWindowListener method 917 dispose method 917 pack method 936 window event 917 window event-handling methods 518 window events 917 window gadgets 474, 1108 windowActivated method of interface WindowListener 917 WindowAdapter class 519, 1079 windowClosed method of interface WindowListener 917, 1079 windowClosing method of interface WindowListener 917 WindowConstants interface 916 DISPOSE_ON_CLOSE constant 917 DO_NOTHING_ON_CLOSE constant 916 HIDE_ON_CLOSE constant 916 windowDeactivated method of interface WindowListener 917 windowDeiconified method of interface WindowListener 917 windowIconified method of interface WindowListener 917 windowing system 480 WindowListener interface 518, 519, 917, 1079 windowActivated method 917 windowClosed method 917, 1079 windowClosing method 917 windowDeactivated method 917 windowDeiconified method 917 windowIconified method 917 windowOpened method 917 windowOpened method of interface WindowListener 917 Windows 13, 168, 653 Windows look-and-feel 912 Windows operating system 13 word character 624 word processor 597, 605 workflow 104 World Population Growth Calculator exercise 68 World Population Growth exercise 151 World Wide Web 26 World Wide Web (WWW) browser 90 World Wide Web Consortium (W3C) 26 worst-case run time for an algorithm 814 wrapper methods of the Collections class 688 wrapper object (collections) 721 wrapping stream objects 662, 667 wrapping text in a JTextArea 542 writeBoolean method of interface DataOutput 674 writeByte method of interface DataOutput 674 writeBytes method of interface DataOutput 674 writeChar method of interface DataOutput 674 writeChars method of interface DataOutput 674 writeDouble method of interface DataOutput 674 writeFloat method of interface DataOutput 674 writeInt method of interface DataOutput 674 writeLong method of interface DataOutput 674 writeObject method of class ObjectOutputStream 667 of interface ObjectOutput 663 Writer class 675 writeShort method of interface DataOutput 674 writeUTF method of interface DataOutput 674 Writing the Word Equivalent of a Check Amount 640 www 28 X x-coordinate 135, 556, 580 X_AXIS constant of class Box 942 x-axis 135, 556 Y y-coordinate 135, 556, 580 Y_AXIS constant of class Box 942 y-axis 135, 556 Z zero-based counting 156 ZERO constant of class BigDecimal 347 ZERO constant of class BigInteger 784 zero-based counting 248 zeroth element 245 This page intentionally left blank Additional Comments from Recent Editions Reviewers ` Fantastic textbook and reference Provides great detail on the latest Java features including lambdas The code examples make it easy to understand the concepts.a—Lance Andersen, Principal Member of the Technical Staff, Oracle Corporation ` If you think a 10th edition is just going to be a repeat then you would not this book justice It has the breadth and depth to get a beginning Java programmer started, but at the same time it is a good companion for a more seasoned programmer who wants to get updated to the latest version of Java Perfect introduction to strings Good explanation of static vs non-static methods and variables Best introduction to Java 2D I’ve seen! The collections framework is well explained Good introduction to the most essential data structures A nice introduction to JavaFX.a —Manfred Riem, Java Champion ` Clearly describes the use cases for different parts of the Java APIs The tips and observations are very useful Clearly explains opportunities and pitfalls in Java Rather than telling the reader what to and not do, the rationale behind these opportunities and pitfalls is explained The new features introduced in Java are well mixed with older functionality.a—Johan Vos, LodgON and Java Champion ` Really good, clear explanation of object-oriented programming fundamentals Excellent polymorphism chapter Covers all the essentials of strings Good to see things like try-with-resources and DirectoryStream being used Excellent generic collections chapter Covering lambdas and streams in one chapter is a tough challenge; you’ve done pretty well Concurrency chapter gives good coverage of numerous aspects Good data structures chapter Introduces JavaFX, the great new way to develop client applications in Java; I like the use of Scene Builder to create the GUI with drag-and-drop design rather than doing it by hand, which shows the way it should be done.a—Simon Ritter, Oracle Corporation ` GUI examples are very good and the exercises are well thought out Graphics examples are easy to follow; good and challenging exercises Recursion is a well-written chapter; factorials, the Fibonacci series and the Tower of Hanoi are good examples The JavaFX GUI chapter provides a solid introduction to using the JavaFX Scene Builder demonstrating how easy it is to create Java-based GUI applications.a—Lance Andersen, Principal Member of the Technical Staff, Oracle Corporation ` The Making a Difference exercises are well thought through I like the DeckOfCards example [in the Arrays and ArrayLists chapter] The evolving inheritance example is a good approach to motivating inheritance I like the employee [polymorphism] example Very thorough and well explained GUI chapter; I liked the layout exercises Thorough strings chapter; I like the clear definitions of regular expressions and the Pig Latin exercise Good introduction to collections; Hashtable performance discussion was good I like the summary of searching and sorting algorithms with Big O values Solid treatment of threading.a—Dr Danny Coward, Oracle Corporation ` Nice breadth of coverage of traditional core Java and programming topics as well as newer areas such as lambda expressions and areas becoming more critical such as concurrent programming A fine intro chapter I like the [Intro to Classes] bank account example [Arrays and ArrayLists] is a fine chapter [Classes and Objects: A Deeper Look] provides a good examination of data type creation Nice chapter on exception handling Very nice coverage of files, streams and object serialization Very nice chapter on generics Nice overview of hand-managed node-based data structures.a—Evan Golub, University of Maryland ` I like the references to big data, Moore’s Law and encapsulation The inheritance chapter is excellent; examples are gender neutral which is perfect; the University Community Member inheritance hierarchy is a great example.a —Khallai Taylor, Assistant Professor, Triton College and Adjunct Professor, Lonestar College—Kingwood ` Good approach to important concepts like static, accessors and private fields and their validation Good explanation of control statements, and translating from pseudocode to a Java program [Classes and Objects: A Deeper Look] coverage is very interesting—I like how the book flows Excellent explanation of Java SE interfaces Excellent explanation of exceptions.a—Jorge Vargas, Yumbling and a Java Champion ` Very interesting and entertaining introduction Good job explaining arrays before the more abstract collections Guiding the reader to avoid dangerous patterns is equally important as explaining the correct syntax; great work! Excellent introduction to object-oriented concepts; rather than just a theoretical overview, it points the reader to how OO is implemented Great polymorphism chapter—should help the reader distinguish between abstract classes and Java interfaces with default methods Good discussion of analyzing stack traces, since exceptions provide useful debugging information Great job explaining Java2D Shows how easily files and the file system are accessible using Java Very good introduction to hashtables Pushing all lambda-related content into a single chapter is hard, but the authors succeeded; I like the way they show how lambda expressions compare to existing code with inner classes; they show that it’s the compiler that does the work Recursion is well explained Great introduction to BigInteger and BigDecimal One of the best explanations of generics I’ve read Clearly explains collections, and when and how they should be used; it’s important that developers understand this, since choosing a wrong implementation can lead to massive performance penalties or hard-to-understand programs The explanations of linked lists, stacks and queues are excellent.a—Johan Vos, LodgON and Java Champion ONLINE ACCESS Thank you for purchasing a new copy of Java™ How to Program, Tenth Edition, Early Objects Your textbook includes 12 months of prepaid access to the book’s Companion Website This prepaid subscription provides you with full access to the following student support areas: • VideoNotes (step-by-step video tutorials specifically designed to enhance the programming concepts presented in this textbook) • Source code • Premium web chapters and appendices Additional Comments from Recent Editions Reviewers ❝ Updated to reflect the state of the art in Java technologies; deep and crystal clear explanations The social-consciousness [Making a Difference] exercises are something new and refreshing Nice introduction to Java networking.~—José Antonio González Seco, Parliament of Andalusia ❝An easy-to-read conversational style Clear code examples propel readers to become proficient in Java.~—Patty Kraft, San Diego State U ❝ The [early] introduction of the class concept is clearly presented A comprehensive overview of control structures and the pitfalls that befall new programmers I applaud the authors for their topical research and illustrative examples The arrays exercises are sophisticated and interesting The clearest explanation of pass-by-value and pass-by-reference that I’ve encountered A logical progression of inheritance and the rationale for properly implementing encapsulation in a system involving an inheritance hierarchy The polymorphism and exception handling discussions are the best I’ve seen An excellent strings chapter I like the [recursion] discussions of the ‘Lo Fractal’ and backtracking (which is useful in computer vision applications) A good segue into a data structures course.~—Ric Heishman, George Mason University ❝ Practical top-down, solution approach to teaching programming basics, covering pseudocode, algorithm development and activity diagrams Of immense value to practitioners and students of the object-oriented approach Demystifies inheritance and polymorphism, and illustrates their use in getting elegant, simple and maintainable code The [optional] OO design case study presents the object-oriented approach in a simple manner, from requirements to Java code.~—Vinod Varma, Astro Infotech Private Limited ❝ Easy-to-follow examples provide great teaching opportunities! I like the [optional] graphics track early in the book—the exercises will be fun Use a coin to scratch off the coating and reveal your student access code Do not use a knife or other sharp object as it may damage the code To access the Java How to Program, Tenth Edition, Early Objects Companion Website for the first time, you will need to register online using a computer with an Internet connection and a web browser The process takes just a couple of minutes and only needs to be completed once Go to http://www.pearsonhighered.com/deitel/ Click on Companion Website Click on the Register button On the registration page, enter your student access code* found beneath the scratchoff panel Do not type the dashes You can use lower- or uppercase Follow the on-screen instructions If you need help at any time during the online registration process, simply click the Need Help? icon for the students OO design techniques are incorporated throughout The concept of inheritance is built through examples and is very understandable Great examples of polymorphism and interfaces Great comparison of recursion and iteration The searching and sorting chapter is just right A simplified explanation of Big O—the best I’ve read! I appreciate the coverage of GUI threading issues Great approach to Java web technologies.~ —Sue McFarland Metzger, Villanova University ❝ The Making a Difference exercises are inspired—they have a real contemporary feeling, both in their topics and in the way they encourage the student to gather data from the Internet and bring it back to the question at hand.~—Vince O’Brien, Pearson Education (our publisher) ❝ Most major concepts are illustrated by complete, annotated programs Abundant exercises hone your understanding of the material JDBC is explained well.~—Shyamal Mitra, University of Texas at Austin ❝ The best introductory textbook that I’ve encountered I wish I had this book when I was learning how to program! Good introduction to the software engineering process.~—Lance Andersen, Oracle Corporation ❝ You’ll be well on your way to becoming a great Java programmer with this book.~—Peter Pilgrim, Java Champion, Consultant ❝ A good objects-early introduction to Java Exceptionally well-written recursion chapter Excellent descriptions of the search and sort algorithms and a gentle introduction to Big-O notation—the examples give the code for the algorithms, and output that creates a picture of how the algorithms work.~—Diana Franklin, University of California, Santa Barbara ❝ Suitable for new programmers, intermediate-level programmers who want to hone their skills, and expert programmers who need a well-organized reference Event handling and layouts are well explained.~—Manjeet Rege, Rochester Institute of Technology ❝Beautiful collections of exercises—a nice illustration of how to use Java to generate impressive graphics.~—Amr Sabry, Indiana University Once your personal Login Name and Password are confirmed, you can begin using the Java How to Program, Tenth Edition, Early Objects Companion Website! ❝ The [optional] OOD ATM case study puts many concepts from previous chapters together in a plan for a large program, showing the object-oriented design process—the discussion of inheritance and polymorphism is especially good as the authors integrate these into the design.~ To log in after you have registered: ❝ The transition from design to implementation is explained powerfully—the reader can easily understand the design issues and how to implement them in Java.~—S Sivakumar, Astro Infotech Private Limited You only need to register for this Companion Website once After that, you can log in any time at http://www.pearsonhighered.com/deitel/ by providing your Login Name and Password when prompted *Important: The access code can only be used once This subscription is valid for 12 months upon activation and is not transferable If this access code has already been revealed, it may no longer be valid If this is the case, you can purchase a subscription at http://www.pearsonhighered.com/deitel/, by going to the Java How to Program, Tenth Edition, Early Objects book and following the on-screen instructions —Susan Rodger, Duke University ❝ Comprehensive introduction to Java, now in its eighth major iteration With clear descriptions, useful tips and hints, and well thought out exercises, this is a great book for studying the world’s most popular programming language.~—Simon Ritter, Oracle Corporation ❝ Comprehensive treatment of Java programming, covering both the latest version of the language and Java SE APIs, with its concepts and techniques reinforced by a plethora of well-thought-through exercises.~—Dr Danny Coward, Oracle Corporation ❝ There are many Java programming books in the world This textbook is the best one If you like to introduce object-oriented programming early and smoothly, then this is the right one for you!~—Dr Huiwei Guan, North Shore Community College More Comments on Facing Page