SlideShare a Scribd company logo
(eBook PDF) Introduction to Programming with
Java: A Problem Solving Approach 3rd Edition
download
https://ebookluna.com/product/ebook-pdf-introduction-to-
programming-with-java-a-problem-solving-approach-3rd-edition/
Download more ebook from https://ebookluna.com
John Dean
Park University
Raymond Dean
University of Kansas
JAVA
WITH
A Problem Solving Approach
Introduction to Programming
dea75768_fm_i-xxxviii.indd 1 4/30/20 11:54 AM
12.10. Empty Statement 552
12.11. Using break to Exit from a Loop 554
12.12. for Loop Header Details 555
12.13. Enumerated Types 557
12.14. forEach Method, Lambda Expressions,
Method References, and Streams 564
12.15. Hexadecimal, Octal, and Binary
Numbers 573
12.16. GUI Track: Unicode (Optional) 574
12.17. Introduction to GridWorld Case Study
(Optional) 579
CHAPTER 13
Aggregation, Composition,
and Inheritance 591
13.1. Introduction 592
13.2. Composition and Aggregation 592
13.3. Inheritance Overview 599
13.4. Implementation of a Person/Employee/
FullTime Hierarchy 603
13.5. Constructors in a Subclass 605
13.6. Method Overriding 606
13.7. Using the Person/Employee/FullTime
Hierarchy 609
13.8. The final Access Modifier 610
13.9. Using Inheritance with Aggregation and
Composition 610
13.10. Design Practice with Card Game
Example 613
13.11. GridWorld Case Study Extensions
(Optional) 619
13.12. Problem Solving with Association Classes
(Optional) 626
CHAPTER 14
Inheritance and Polymorphism 637
14.1. Introduction 638
14.2. The Object Class and Automatic Type
Promotion 638
14.3. The equals Method 639
14.4. The toString Method 643
14.5. Polymorphism and Dynamic Binding 648
14.6. Assignments When the Two Sides’ Classes
Are Different 653
14.7. Polymorphism with Arrays 654
14.8. abstract Methods and Classes 660
14.9. Interfaces 663
14.10. The protected Access Modifier 673
14.11. GUI Track: Three-Dimensional Graphics
(Optional) 677
CHAPTER 15
Exception Handling 691
15.1. Introduction 692
15.2. Overview of Exceptions and Exception
Messages 692
15.3. Using try and catch Blocks to Handle
“Dangerous” Method Calls 693
15.4. Line Plot Example 695
15.5. try Block Details 699
15.6. Two Categories of Exceptions—Checked and
Unchecked 700
15.7. Unchecked Exceptions 702
15.8. Checked Exceptions 705
15.9. Generic catch Block with Exception
Class 708
15.10. Multiple catch Blocks and Multiple
Exceptions per Block 712
15.11. Understanding Exception Messages 714
15.12. Using a throws Clause to Postpone the
catch 718
15.13. Automatic Cleanup Using Try-With-
Resources 720
15.14. GUI Track: Line Plot Example Revisited
(Optional) 722
CHAPTER 16
Files, Buffers, Channels, and Paths 735
16.1. Introduction 736
16.2. Simple Text-File Example: HTML
File Generator 737
16.3. A Website Reader 741
16.4. Object File I/O 743
16.5. Character Sets and File-Access
Options 748
16.6. Buffered Text File I/O 749
16.7. Primitive Buffers with Random Access 752
16.8. Channel I/O and Memory-Mapped Files 760
viii Contents
dea75768_fm_i-xxxviii.indd 8 4/30/20 11:54 AM
16.9. Path, Whole-File, and Directory
Operations 767
16.10. Walking a Directory Tree 769
16.11. GUI Track: Final Iteration of Problem
Solving with CRC Cards (Optional) 775
CHAPTER 17
GUI Programming Basics 787
17.1. Introduction 788
17.2. SimpleWindow Program 791
17.3. Stage and Scene 794
17.4. JavaFX Components 796
17.5. Label Control 797
17.6. TextField Control 799
17.7. Greeting Program 801
17.8. Event Handling 805
17.9. Property Binding 809
17.10. JavaFX CSS 812
17.11. Scene Graph Inheritance 818
17.12. Style Sheets and Cascading 821
17.13. Button Control and FactorialButton
Program 826
17.14. Distinguishing Between Multiple Events 832
17.15. Colors 834
17.16. ColorChooser Program 838
CHAPTER 18
GUI Programming—Layout Panes 849
18.1. Introduction 849
18.2. Layout Panes 851
18.3. FlowPane and GridPane—Competing
Layout Philosophies 853
18.4. VBox Program with Two Stages and an
Image File 858
18.5. BorderPane 867
18.6. TilePane and TextFlow Containers 872
18.7. TicTacToe Program 878
18.8. Embedded Panes, HBox, and MathCalculator
Program 882
18.9. Plain Pane Container and Component
Positioning 889
CHAPTER 19
GUI Programming—Additional GUI
Components, Additional Event Handlers,
Animation 896
19.1. Introduction 897
19.2. User Interface Design 897
19.3. TextArea Control 898
19.4. CheckBox and RadioButton Controls 903
19.5. ComboBox Control 909
19.6. Job Application Program 913
19.7. ScrollPane and Menu Classes 918
19.8. Images and Mouse Events 922
19.9. Lunar Eclipse Program with Circle,
RadialGradient, and Slider 928
19.10. Animation 933
Appendices
Appendix 1	
ASCII Character Set 943
Appendix 2 Operator Precedence 945
Appendix 3 Java Keywords and Other Reserved
Words 947
Appendix 4 Packages and Modules 951
Appendix 5 Java Coding-Style Conventions 963
Appendix 6 Javadoc with Tags 975
Appendix 7 UML Diagrams 980
Appendix 8	
Number Systems and Conversions
Between Them 986
Additional Online Material
Chapter S6	
Writing Methods in a Non-Object-
Oriented Environment
Chapter S9	
Arrays in a Non-Object-Oriented
Environment
Chapter S17	
GUI Programming Basics
Chapter S18	
GUI Programming—Component
Layout, Additional GUI Components
Appendix 9 Multithreading
Index 990
Contents ix
dea75768_fm_i-xxxviii.indd 9 5/12/20 1:41 PM
x
In this book, we lead you on a journey into the fun and exciting world of computer programming. Through-
out your journey, we’ll provide you with lots of problem-solving practice. After all, good programmers
need to be good problem solvers. We’ll show you how to implement your problem solutions with Java
programs. We provide a plethora of examples, some short and focused on a single concept, some longer and
more “real world.” We present the material in a conversational, easy-to-follow manner aimed at making
your journey a pleasant one. When you’re done with the book, you should be a proficient Java programmer.
Our textbook targets a wide range of readers. Primarily, it targets students in a standard college-level
“Introduction to Programming” course or course sequence where no prerequisite programming experience
is assumed. We have included the topics recommended by the College Board for high school students
studying for advanced placement (AP) in computer science. So this text should be good for those students
as well.
In addition to targeting students with no prerequisite programming experience, our textbook targets
industry practitioners and college-level students who have some programming experience and want to
learn Java. This second set of readers can skip the early chapters on general programming concepts and
focus on the features of Java that differ from the languages that they already know. In particular, because
C++ and Java are similar, readers with a C++ background should be able to cover the textbook in a single
three-credit-hour course. (But we should reiterate for those of you with no programming experience:
No prerequisite programming experience is required in order to use this text.)
Finally, our textbook targets those who are learning Java on their own, outside of a classroom environ-
ment. This third set of readers should read the entire textbook at a pace determined on a case-by-case basis.
What’s New in This Edition?
The changes in this edition are big and small. Big changes include new chapters, reorganized chapter sec-
tions, new programming constructs, new program examples, and new exercises. Smaller changes include
updating explanations and anecdotes. We’ve combed the entire book for opportunities to improve the
book’s clarity and readability. The following list highlights the more significant changes that we’ve made
to this edition.
∙ Introductory Chapter
	
To keep up with the computer industry’s growth, we’ve made quite a few changes to Chapter 1, such
as updating the information in the computer hardware and Java history sections.
∙ Switching Constructs
	
Java 12 and Java 13 made improvements to the venerable switch statement, and this edition describes
those improvements. We use the new switching techniques (multiple comma-­
separated case constants
and no break statements) for programs throughout the book. And we use switch statements versus
switch expressions according to what the problem calls for. If you’re a fan of the old-style switch
statement, no worries, we provide a description early on which will help you with legacy code.
Preface
dea75768_fm_i-xxxviii.indd 10 4/30/20 11:54 AM
Preface xi
∙ Local Variable Type Inferencing
	
Java 10 introduced the ability to use var as a type (rather than int, double, etc.) for a local variable
declaration where the declaration is part of an initialization. We describe the new syntax, but for self-
documentation reasons, we stick with traditional explicit type declarations for the most part.
∙ Name Change for Static Variables and Static Methods
	
The powers that be (the Oracle documentation folks) now use the terms static variable and static
method for what used to be known as class variable and class method, so we’ve updated accordingly.
∙ Miscellaneous Java API Library Updates
	
With the new Java releases since the second edition, there have been quite a few updates to the Java
API library. We’ve updated our discussions and programs with new API method and constructor calls
when appropriate. Most of our new API content can be found in our GUI coverage, but there are other
API changes sprinkled throughout the book. For example, with Java’s deprecation of the wrapper
class constructors, we’ve refactored our programs to rely on the wrapper classes’ valueOf methods.
∙ New Section—forEach Method and Streams
	
We introduce the forEach method as a simple alternative to the for-each loop in the context of an
ArrayList. We then use the forEach method in the context of streams, where it really shines. We
describe streams in depth, with their exciting potential to take advantage of parallel processing to
improve a program’s efficiency.
∙ Lambda Expressions and Method References
	
Lambda expressions and method references are techniques that allow you to implement the function-
ality of a method so you can use it as an argument in a method call. We first present lambda expres-
sions and method references as arguments for a forEach method call. Later, we use lambda expressions
and method references extensively to help with the GUI programs.
∙ Interfaces with Static Methods and Default Methods
	
We’ve rewritten Chapter 14’s section on interfaces to include a discussion of static methods and
default methods. Oracle added them to interfaces because they support an interface’s ability to imple-
ment multiple inheritance effectively.
∙ End-of-Chapter GUI Sections
	
We’ve rewritten all of our end-of-chapter GUI sections to take advantage of Java’s newer GUI constructs.
∙ Three New Chapters—JavaFX
	
In this book’s second edition, we used the AWT and Swing platforms for our two GUI chapters. This
third edition moves those chapters to the book’s website. We provide three new chapters in the main
body of the book that describe GUI programming using the JavaFX platform. As part of that presenta-
tion, you’ll learn how to format your programs using JavaFX CSS properties.
∙ New Appendix—Modules
	
In Appendix 4, we introduce modules, which allow you to group together packages. Modules make it
easier to organize and share classes for different programming needs. They are used to facilitate the
configuration of Java software for diverse hardware and software platforms.
dea75768_fm_i-xxxviii.indd 11 5/10/20 8:49 PM
xii Preface
∙ New Exercises
	
We have substantially changed most of the exercises and altered almost all of them in some way. As
before, we provide exercise solutions on the password-protected instructor’s portion of the book’s
website.
Compliant with the College Board’s AP
Computer Science A Curriculum
We have put a great deal of effort into ensuring that this textbook is compliant with the College Board’s
Advanced Placement (AP) Computer Science A curriculum content. It follows all the AP Computer
Science A guidelines. As such, it appears on the College Board’s approved textbook list at
https://apcentral.collegeboard.org/courses/ap-computer-science-a/course-audit.
Textbook Cornerstone #1: Problem Solving
Being able to solve problems is a critical skill that all programmers must possess. We teach programmatic
problem solving by emphasizing two of its key elements—algorithm development and program design.
Emphasis on Algorithm Development
In Chapter 2, we immerse readers into algorithm development by using pseudocode for the algorithm
examples instead of Java. In using pseudocode, students are able to work through nontrivial problems on
their own without getting bogged down in Java syntax—no need to worry about class headings, semico-
lons, braces, and so on.1
Working through nontrivial problems enables students to gain an early apprecia-
tion for creativity, logic, and organization. Without that appreciation, Java students tend to learn Java
syntax with a rote-memory attitude. But with that appreciation, students tend to learn Java syntax more
quickly and effectively because they have a motivational basis for learning it. In addition, they are able to
handle nontrivial Java homework assignments fairly early because they have prior experience with simi-
larly nontrivial pseudocode homework assignments.
In Chapter 3 and in later chapters, we rely primarily on Java for algorithm-development examples. But
for the more involved problems, we sometimes use high-level pseudocode to describe first-cut proposed
solutions. Using pseudocode enables readers to bypass syntax details and focus on the algorithm portion
of the solution.
Emphasis on Program Design
Problem solving is more than just developing an algorithm. It also involves figuring out the best imple-
mentation for the algorithm. That’s program design. Program design is extremely important, and that’s
why we spend so much time on it. Frequently, we explain the thought processes that a person might go
through when coming up with a solution. For example, we explain how to choose between different loop
types, how to split up a method into multiple methods, how to decide on appropriate classes, how to
1
Inevitably, we use a particular style for our pseudocode, but we repeatedly emphasize that other pseudocode styles are fine so long
as they convey the intended meaning. Our pseudocode style is a combination of free-form description for high-level tasks and more
specific commands for low-level tasks. We’ve chosen a pseudocode style that is intuitive, to welcome new programmers, and struc-
tured, to accommodate program logic.
dea75768_fm_i-xxxviii.indd 12 4/30/20 11:54 AM
Preface xiii
choose between instance and static members, and how to determine class relationships using inheritance
and composition. We challenge students to find the most elegant implementations for a particular task.
We devote a whole chapter to program design—Chapter 8, “Software Engineering.” In that chapter,
we provide an in-depth look at coding-style conventions and documentation for programmers and users.
We discuss design strategies like separation of concerns, modularization, and encapsulation. Also in the
chapter, we describe alternative design strategies—top-down, bottom-up, case-based, and iterative
enhancement.
Problem-Solving Sections
We often address problem solving (algorithm development and program design) in the natural flow of
explaining concepts. But we also cover problem solving in sections that are wholly devoted to it. In each
problem-solving section, we present a situation that contains an unresolved problem. In coming up with a
solution for the problem, we try to mimic the real-world problem-solving experience by using an iterative
design strategy. We present a first-cut solution, analyze the solution, and then discuss possible improve-
ments to it. We use a conversational trial-and-error format (e.g., “What type of layout manager should
we use? We first tried the GridLayout manager. That works OK, but not great. Let’s now try the
BorderLayout manager.”). This casual tone sets the student at ease by conveying the message that it is
normal, and in fact expected, that a programmer will need to work through a problem multiple times
before finding the best solution.
Additional Problem-Solving Mechanisms
We include problem-solving examples and problem-solving advice throughout the text (not just in
Chapter 2, Chapter 8, and the problem-solving sections). As a point of emphasis, we insert a problem-
solving box, with an icon and a succinct tip, next to the text that contains the problem-solving example
and/or advice.
We are strong believers in learning by example. As such, our textbook contains a multitude of com-
plete program examples. Readers are encouraged to use our programs as recipes for solving similar pro-
grams on their own.
Textbook Cornerstone #2: Fundamentals First
Postpone Concepts That Require Complex Syntax
We feel that many introductory programming textbooks jump too quickly into concepts that require com-
plex syntax. In using complex syntax early, students get in the habit of entering code without fully under-
standing it or, worse yet, copying and pasting from example code without fully understanding the example
code. That can lead to less-than-ideal programs and students who are limited in their ability to solve a wide
variety of problems. Thus, we prefer to postpone concepts that require complex syntax. We prefer to intro-
duce such concepts later on, when students are better able to understand them fully.
As a prime example of that philosophy, we cover the simpler forms of GUI programming early (in
an optional graphics track), but we cover the more complicated forms of GUI programming later in the
book. Specifically, we postpone event-driven GUI programming until the end of the book. This is dif-
ferent from some other Java textbooks, which favor early full immersion into event-driven GUI pro-
gramming. We feel that strategy is a mistake because proper event-driven GUI programming requires a
great deal of programming maturity. When they learn it at the end of the book, our readers are better
able to understand it fully.
dea75768_fm_i-xxxviii.indd 13 4/30/20 11:54 AM
xiv Preface
Tracing Examples
To write code effectively, it’s imperative to understand code thoroughly. We’ve found that step-by-step
tracing of program code is an effective way to ensure thorough understanding. Thus, in the earlier parts of
the textbook, when we introduce a new programming structure, we often illustrate it with a meticulous
trace. The detailed tracing technique we use illustrates the thought process programmers employ while
debugging. It’s a printed alternative to the sequence of screen displays generated by debuggers in inte-
grated development environment (IDE) software.
Input and Output
In the optional GUI-track sections and in the GUI chapters at the end of the book, we use GUI commands
for input and output (I/O). But because of our emphasis on fundamentals, we use console commands for
I/O for the rest of the book.2
For console input, we use the Scanner class. For console output, we use the
standard System.out.print, System.out.println, and System.out.printf methods.
Textbook Cornerstone #3: Real World
More often than not, today’s classroom students and industry practitioners prefer to learn with a hands-
on, real-world approach. To meet this need, our textbook and its associated website include:
∙ compiler tools
∙ complete program examples
∙ practical guidance in program design
∙ coding-style guidelines based on industry standards
∙ Unified Modeling Language (UML) notation for class relationship diagrams
∙ practical homework-project assignments
Compiler Tools
We do not tie the textbook to any particular compiler tool—you are free to use any compiler tool(s) that you
like. If you do not have a preferred compiler in mind, then you might want to try out one or more of these:
∙ Java Standard Edition Development Kit (JDK), by Oracle
∙ TextPad, by Helios
∙ Eclipse, by the Eclipse Foundation
∙ Netbeans, backed by Oracle
∙ BlueJ, by the University of Kent and Deaken University
To obtain the above compilers, visit our textbook website at http://www.mhhe.com/dean3e, find the
appropriate compiler link(s), and download away for free.
Complete Program Examples
In addition to providing code fragments to illustrate specific concepts, our textbook contains lots of com-
plete program examples. With complete programs, students are able to (1) see how the analyzed code ties
in with the rest of a program, and (2) test the code by running it.
2
We introduce GUI I/O at the end of Chapter 3 with dialog boxes. That opens up an optional door for GUI fans. If readers are so
inclined, they can use the Alert, TextInputDialog, and ChoiceDialog classes to implement all our programs with GUI
I/O rather than console I/O.
dea75768_fm_i-xxxviii.indd 14 4/30/20 11:54 AM
Preface xv
Coding-Style Conventions
We include coding-style tips throughout the textbook. The coding-style tips are based on Oracle’s coding
conventions (https://www.oracle.com/technetwork/java/codeconvtoc-136057.html), Google’s coding con-
ventions (https://google.github.io/styleguide/javaguide.html), and industry practice. In Appendix 5, we
provide a complete reference for the book’s coding-style conventions and an associated example program
that illustrates these conventions.
UML Notation
UML has become a standard for describing the entities in large software projects. Rather than overwhelm
beginning programmers with syntax for the entire UML (which is quite extensive), we present a subset of
UML. Throughout the textbook, we incorporate UML notation to represent classes and class relationships
pictorially. For those interested in more details, we provide additional UML notation in Appendix 7.
Homework Problems
We provide homework problems that are illustrative, practical, and clearly worded. The problems range
from easy to challenging. They are grouped into three categories—review questions, exercises, and proj-
ects. We include review questions and exercises at the end of each chapter, and we provide projects on our
textbook’s website.
The review questions tend to have short answers, and the answers are in the textbook. The review
questions use these formats: short-answer, multiple-choice, true/false, fill-in-the-blank, tracing,
debugging, and write a code fragment. Each review question is based on a relatively small part of the
chapter.
The exercises tend to have short to moderate-length answers, and the answers are not in the textbook.
The exercises use these formats: short-answer, tracing, debugging, and write a code fragment. Exercises
are keyed to the highest prerequisite section number in the chapter, but they sometimes integrate concepts
from several parts of the chapter. For this third edition, we have changed almost all of the end-of-chapter
exercises, including exercises associated with unchanged material in the body of the text.
The projects consist of problem descriptions whose solutions are complete programs. Project solu-
tions are not in the textbook. Projects require students to employ creativity and problem-solving skills and
apply what they’ve learned in the chapter. These projects often include optional parts, which provide chal-
lenges for the more talented students. Projects are keyed to the highest prerequisite section number in the
chapter, but they often integrate concepts from several preceding parts of the chapter. For this third edition,
we have modified old projects and added new projects to make all projects conform to content in the body
of the current text. Because the most substantial body-of-text changes are in the final three chapters, most
of the project modifications and additions are associated with these chapters.
An important special feature of this book is the way that it specifies problems. “Sample sessions”
show the precise output generated for a particular set of input values. These sample sessions include inputs
that represent typical situations and sometimes also extreme or boundary situations.
Academic-Area Projects
To enhance the appeal of projects and to show how the current chapter’s programming techniques might
apply to different areas of interest, we take project content from several academic areas:
∙ computer science and numerical methods
∙ business and accounting
dea75768_fm_i-xxxviii.indd 15 4/30/20 11:54 AM
xvi Preface
∙ social sciences and statistics
∙ math and physics
∙ engineering and architecture
∙ biology and ecology
Most of the academic-area projects do not require prerequisite knowledge in a particular area. Thus,
instructors are free to assign almost any of the projects to any of their students. To provide a general reader
with enough specialized knowledge to work a problem in a particular academic area, we sometimes expand
the problem statement to explain a few special concepts in that academic area.
Most of the academic-area projects do not require students to have completed projects from earlier
chapters; that is, most projects do not build on previous projects. Thus, for the most part, instructors are
free to assign projects without worrying about prerequisite projects. In some cases, a project repeats a
previous chapter’s project with a different approach. The teacher may elect to take advantage of this rep-
etition to dramatize the availability of alternatives, but this is not necessary.
Project assignments can be tailored to fit readers’ needs. For example:
∙ For readers outside of academia—
Readers can choose projects that match their interests.
∙ When a course has students from one academic area—
Instructors can assign projects from the relevant academic area.
∙ When a course has students with diverse backgrounds—
	
Instructors can ask students to choose projects from their own academic areas, or instructors can
ignore the academic-area delineations and simply assign projects that are most appealing.
To help you decide which projects to work on, we’ve included a “Project Summary” section after the
preface. It lists all the projects by chapter and section, and for each project, it specifies:
∙ prerequisite chapter and section
∙ academic area
∙ estimated difficulty
∙ a title and brief description
After using the “Project Summary” section to get an idea of which projects you might like to work on, see
the textbook’s website for the full project descriptions.
Organization
In writing this book, we lead readers through three important programming methodologies: structured
programming, OOP, and event-driven programming. For our structured programming coverage, we intro-
duce basic concepts such as variables and operators, if statements, and loops. Then we show readers how
to call prebuilt methods from Oracle’s Java API library. Many of these methods, like those in the Math
class, are non-OOP methods that can be called directly. Others, like those in the String class, are OOP
methods that must be called by a previously created object. After an “interlude” that gives readers a brief
taste of what it’s like to write methods in a non-OOP environment, we move into OOP programming, and
introduce basic OOP concepts such as classes, objects, instance variables, instance methods, and construc-
tors. We also introduce static variables and static methods, which are useful in certain situations. However,
we note that they should be used less often than instance variables and instance methods. Next, we move
dea75768_fm_i-xxxviii.indd 16 4/30/20 11:54 AM
Preface xvii
on to more advanced OOP concepts—arrays, collections, interfaces, and inheritance. Chapters on excep-
tion handling and files provide a transition into event-driven GUI programming. We describe and employ
event-driven GUI programming in the final three chapters.
The content and sequence we promote enable students to develop their skills from a solid foundation
of programming fundamentals. To foster this fundamentals-first approach, our book starts with a mini-
mum set of concepts and details. It then gradually broadens concepts and adds detail later. We avoid over-
loading early chapters by deferring certain less-important details to later chapters.
GUI Track
Many programmers find Graphical User Interface (GUI) programming to be fun. As such, GUI program-
ming can be a great motivational tool for keeping readers interested and engaged. That’s why we include
graphics sections throughout the book, starting in Chapter 1. We call those sections our “GUI track.” Most
of these end-of-chapter sections use GUI code that complements the current chapter’s previously pre-
sented non-GUI material. For readers who do not have time for the GUI track, no problem. Any or all of
the GUI track sections may be skipped because the rest of the book does not depend on any of the GUI-
track material.
Although the rest of the book does not depend on the GUI-track material, be aware that some of the
GUI-track sections depend on some of the material in prior GUI-track sections:
∙ Chapter 3’s GUI section introduces dialog boxes for user input, and dialog boxes are used in later GUI
sections for Chapters 10, 11, 15, and 16.
∙ Chapters 8, 10, and 16 have GUI sections that implement a common program, with iterative enhance-
ments in each new GUI section.
∙ Chapters 12 and 13 have GUI sections that implement a common GridWorld program (for readers
interested in the College Board’s AP Computer Science A curriculum). The GridWorld code uses
AWT and Swing GUI software.
Chapter 1
In Chapter 1, we first explain basic computer terms—what are the hardware components, what is source
code, what is object code, and so on. We then narrow our focus and describe the programming language
we’ll be using for the remainder of the book—Java. Finally, we give students a quick view of the classic
bare-bones “Hello World” program. We explain how to create and run the program using minimalist­
software—Microsoft’s Notepad text editor and Oracle’s command-line JDK tools.
Chapter 2
In Chapter 2, we present problem-solving techniques with an emphasis on algorithmic design. In imple-
menting algorithm solutions, we use generic tools—flowcharts and pseudocode—with pseudocode given
greater weight. As part of our algorithm-design explanation, we describe structured programming tech-
niques. In order to give students an appreciation for semantic details, we show how to trace algorithms.
Chapters 3–5
We present structured programming techniques using Java in Chapters 3–5. Chapter 3 describes sequential
programming basics—variables, input/output, assignment statements, and simple method calls. Chapter 4
describes nonsequential program flow—if statements, switch constructs, and loops. In Chapter 5, we
explain methods in more detail and show readers how to use prebuilt methods in the Java API library.
dea75768_fm_i-xxxviii.indd 17 4/30/20 11:54 AM
xviii Preface
In all three chapters, we teach algorithm design by solving problems and writing programs with the newly
introduced Java syntax.
Interlude
This “mini-chapter” contains two programs that show how to write multiple methods without using OOP.
The Interlude presents a fork in the road between two study sequences. For the standard study sequence,
read the chapters in the standard order (Chapters 1 through 19). For the “objects later” study sequence,
after reading Chapter 5, read the supplemental chapters S6 and S9 online before returning to Chapter 6,
where you’ll begin your study of OOP in earnest.
Chapters 6–7
Chapter 6 introduces the basic elements of OOP in Java. This includes implementing classes and imple-
menting methods and variables within those classes. We use UML class diagrams and object-oriented
tracing techniques to illustrate these concepts.
Chapter 7 provides additional OOP details. It explains how reference variables are assigned, tested for
equality, and passed as arguments to a method. It explains overloaded methods and constructors. It also
explains the use of static variables, static methods, and different types of named constants.
Chapter 8
While the art of program design and the science of computerized problem-solving are developed through-
out the textbook, in Chapter 8, we focus on these aspects in the context of OOP. This chapter begins with
an organized treatment of programming style. It introduces javadoc, the Java application that automati-
cally generates documentation for user-programmers. It describes ways to communicate with users who
are not programmers. It describes organizational strategies like separation of concerns, modularization,
encapsulation, and provision of general-purpose utilities. Coded examples show how to implement these
strategies. It describes the major programming paradigms—top-down design, bottom-up design, using
pre-written software for low-level modules, and prototyping.
Chapters 9–10
Chapter 9 describes arrays, including arrays of primitives, arrays of objects, and multidimensional arrays.
It illustrates array use with complete programs that sort, search, and construct histograms. Chapter 10
describes Java’s powerful array alternative, ArrayList. This provides a simple example of generic-­element
specification. It also introduces the Java Collections Framework, which in turn, provides natural illustrations
of Java interfaces. The prewritten classes in the Java Collections Framework provide a simple introduction of
sets, maps, and queues. A relatively short but complete program shows how the pre-written Java implementa-
tions of these data structures can be used to create and traverse a multiconnected random network.
Chapter 11
Chapter 11 describes another way to process a collection of data—recursion. This chapter includes a
­
discussion of various recursive strategies. It introduces recursion with a real-life example and a familiar
problem that one can solve easily with either looping or recursion. Then it moves gradually to problems
that are harder to solve with looping and more easily solved with recursion. Although this chapter
appears after the chapter on ArrayLists and the Java Collections Framework, it does not depend on
these ­
concepts—it uses just ordinary arrays.
dea75768_fm_i-xxxviii.indd 18 5/12/20 1:23 PM
Preface xix
Chapter 12
Early on, students need to be immersed in problem-solving activities. Covering too much syntax detail
early can detract from that objective. Thus, we initially gloss over some less-important syntax details and
come back to those details later in Chapter 12. This chapter provides more details on items such as these:
∙ byte and short primitive types
∙ Unicode character set
∙ type promotions
∙ postfix versus prefix modes for the increment and decrement operators
∙ conditional operator
∙ short-circuit evaluation
∙ enum data type
∙ forEach method
∙ lambda expressions
∙ method references
∙ streams
The chapter ends with a friendly introduction to a relatively large public-domain program called Grid-
World, which the College Board has used for many years as part of its AP Computer Science A course of
study. This gives students a glimpse of how larger programs are organized.
Chapters 13–14
Chapters 13 and 14 describe class relationships in depth with numerous examples. Chapter 13 describes
aggregation, composition, and inheritance. Chapter 14 describes advanced inheritance-related details such
as the Object class, polymorphism, abstract classes, and the finer points of interfaces. An optional section
at the end of Chapter 13 describes an extension of the GridWorld environment introduced in Chapter 12
and provides additional exposure to Java’s legacy AWT and Swing graphics. Exercises in Chapters 13 and
14 relate material in these two chapters to corresponding GridWorld features.
Chapters 15−16
Chapter 15 describes exception handling, and Chapter 16 describes files. We present exception handling
before files because file-handling code requires the use of exception handling. For example, to open a file
one must check for an exception. In addition to simple text I/O, our treatment of files includes buffering,
random access, channeling, and memory mapping.
Chapters 17−19
As in the end-of-chapter GUI sections, Chapters 17−19 present GUI concepts using the JavaFX platform.
But the programming strategies differ. What follows are the strategies used in Chapters 17–19 (which are
different from the strategies used in the end-of-chapter GUI sections). For user input, the programs use the
components TextField, TextArea, Button, RadioButton, CheckBox, ComboBox, ScrollPane, and Menu.
For layout, the programs use the containers FlowPane, VBox, HBox, GridPane, BorderPane, TilePane, and
TextFlow. For formatting, the programs use JavaFX CSS properties.
Depending on how much and what kind of GUI techniques you’re interested in, you can study one or
more of the end-of-chapter GUI sections or skip all of them. That won’t affect your ability to grasp what’s
in Chapters 17−19. If you’re short on time, you can omit all of the book’s GUI material without compro-
mising your understanding of other material in the book.
dea75768_fm_i-xxxviii.indd 19 5/10/20 8:50 PM
xx Preface
Chapters S17−S18
Chapters S17 and S18 (the S’s stand for supplemental) are posted online. They describe the older Java GUI
platforms—AWT and Swing. The trend has been for new Java programs to use JavaFX, and not AWT and
Swing. However, there’s quite a bit of AWT and Swing code currently in production, and that means
there’s still a need for Java programmers to understand the older techniques so they can update and improve
existing code. So if you find yourself in that position, Chapters S17 and S18 are a good starting point for
learning what you need to know.
Appendices
Most of the appendices cover reference material, like the ASCII character set and the operator precedence
table. For this third edition, we have updated Appendix 4 by including a detailed description of Java modules.
Subject-Matter Dependencies and
Sequence-Changing Opportunities
We’ve positioned the textbook’s material in a natural order for someone who wants fundamentals and also wants
an early introduction to OOP. We feel that our order is the most efficient and effective one for learning how to
become a proficient OOP programmer. Nonetheless, we realize that different readers have different content-
ordering preferences. To accommodate those different preferences, we’ve provided some built-in flexibility.
Figure 0.1 illustrates that flexibility by showing chapter dependencies and, more importantly, chapter
­
nondependencies. For example, the arrow between Chapter 3 and Chapter 4 means that Chapter 3 must be read
prior to Chapter 4. Because there are no arrows going out of Chapters 1, 11, and 16 that point to other complete
chapters, you may skip those chapters without losing prerequisite material that later chapters need. We use
rectangles with rounded corners to indicate chapter sections that you may want to read in advance. If you choose
that option, you’ll want to return to the normal chapter sequence after completing the advanced sections.
Here are some sequence-changing opportunities revealed by Figure 0.1:
∙ Readers can skip Chapter 1, “Introduction to Computers and Programming.”
∙ For an earlier introduction to OOP, readers can read the OOP overview section in Chapter 6 after
reading Chapter 1.
∙ Readers can learn OOP syntax and semantics in Chapter 6 after finishing Java basics in Chapter 3.
∙ For additional looping practice, readers can learn about arrays in Chapter 9 after finishing loops in Chapter 4.
∙ Readers can skip Chapter 11, “Recursion,” and Chapter 16, “Files.”
∙ Readers who prefer a late objects approach can postpone reading Chapter 6, “Object-Oriented Pro-
gramming,” by first reading Chapter S6, “Writing Methods in a Non-Object-Oriented Environment,”
Sections 9.1–9.6 (which explain the basics of arrays), and Chapter S9, “Arrays in a Non-Object-
Oriented Environment.”
∙ For GUI programming, readers who prefer the Swing platform should read Chapters S17 and S18.
To support content-ordering flexibility, the book contains “hyperlinks.” A hyperlink is an optional
jump forward from one place in the book to another place. The jumps are legal in terms of prerequisite
knowledge, meaning that the jumped-over (skipped) material is unnecessary for an understanding of the
later material. We supply hyperlinks for each of the nonsequential arrows in Figure 0.1. For example, we
supply hyperlinks that go from Chapter 1 to Chapter 6 and from Chapter 3 to Chapter 12. For each hyperlink
tail end (in the earlier chapter), we tell the reader where they may optionally jump to. For each hyperlink
target end (in the later chapter), we provide an icon at the side of the target text that helps readers find the
place where they are to begin reading.
dea75768_fm_i-xxxviii.indd 20 5/12/20 1:24 PM
Preface xxi
Figure 0.1 Chapter dependencies
Ch 5: Using Prebuilt Methods
Ch 1: Introduction
Ch 2: Algorithms and Design
Ch 3: Java Basics
Ch 4: Control Statements
§6.2 OOP
Overview
§6.1−§6.8 OOP
Basics
§12.6−§12.12 Alternate
Coding Mechanisms
§9.1−§9.6 Arrays
§12.1−§12.5 Type
Details
Interlude
Ch 8: Software Engineering
Ch 6: Object-Oriented Programming
Ch 7: OOP−Additional Details
§11.1−§11.5 Non-
Array Recursion
§9.1−§9.6 Array Basics
Chapter S6: Writing
Methods in a Non-Object-
Oriented Environment
Chapter S9: Arrays in a
Non-Object-Oriented
Environment
Ch 9: Arrays
Ch 10: ArrayList and
Introduction to Java Collections
Framework
Ch 12: Type Details and Alternate
Coding Mechanisms
Ch 11: Recursion
Ch 13: Aggregation, Composition
and Inheritance
Ch 16: Files
Ch 14: Inheritance and
Polymorphism
Ch 15: Exception
Handling
Ch S17: Swing GUI
Programming Basics
Ch 17: GUI Programming Basics
Ch 18: GUI Programming—
Layout Panes
Ch 19: GUI Programming—
Additional GUI Components,
Additional Event Handlers, Animation
Ch S18: Swing GUI
Component Layout,
Additional GUI Components
dea75768_fm_i-xxxviii.indd 21 4/30/20 11:54 AM
Discovering Diverse Content Through
Random Scribd Documents
It must have been ten o’clock when, as Crellock once more
made his round, he saw that Hallam was asleep, and that
Mrs Hallam had taken up the candle still burning, and with
Julia holding her hand, was looking round the room as if for
a last good-night.
Then together they went to the door, hand in hand; the
door closed; the light shone at the staircase window, then in
their bedroom, where he watched it burn for about a
quarter of an hour before it was extinguished, and all was
dark.
“I shan’t feel satisfied till I have her safe,” he said, as he
walked slowly back to his old look-out that commanded the
road.
The wind came in stronger gusts now, for a few minutes,
and then seemed to die quite away, while the clouds that
overspread the sky grew so dense that it was hard to
distinguish the trees and bushes a dozen yards from where
he stood.
He finished his cigar, thinking out his plans the while, and at
last coming to the conclusion that it was an unnecessary
task this watching, he was about to make one more turn
round the verandah, and then enter by the window and go
to bed, when he fancied he heard a door close, as if blown
by the wind that was once more sighing about the place.
“Just woke up, I suppose,” he said, and he walked towards
the study window and looked in.
Hallam had not moved, but was sleeping heavily in his old
position.
Crellock listened again, but all was perfectly still. It could
not have been fancy. Certainly he had heard a door bang
softly, and the sound seemed to come from this direction.
He stood thinking, and then went round and tried the front
door.
“Fast.”
He walked round to the back door, following the verandah
all the way, and found that door also fast.
“I couldn’t have been mistaken,” he said, as he listened
again.
Once more the wind was sighing loudly about the place, but
the noise was not repeated, and he walked on to the dining-
room window; but as he laid his hand upon the glass door
and thrust it open, a current of air rushed in, and there was
the same sound: a door blew to with a slight bang.
Crellock closed and fastened the glass door as he stepped
out and ran quickly round to the drawing-room, where it
was as he suspected: the glass door similar to that he had
just left was open, and blew to and fro.
“There’s something wrong,” he said excitedly, his suspicions
being aroused; and, dashing in, he upset a chair in crossing
the room, and it fell with a crash, but he hurried on into the
hall, through to the study, and caught Hallam by the arm.
“Wake up!” he said excitedly. “Hallam! Wake up, man.”
He had to shake him heavily before the drink stupefaction
passed off, and then Hallam stood trembling and haggard,
trying to comprehend his companion’s words.
“Wrong?” he said. “Wrong? What’s wrong?”
“I don’t know yet. Look sharp! Run up to your wife’s room.
Take the candle. Quick, man; are you asleep?”
In his dazed state Hallam staggered, and his hand trembled
so that he could hardly keep the light anything like steady.
There was the knowledge, though faintly grasped, that
something was terribly wrong. He gathered that from his
companion’s excited manner, and, stumbling on into the
hall, blundered noisily up the stairs while Crellock stood
breathing hard and listening.
“Here, Millicent! Julie!” he cried hoarsely; “what’s the
matter?”
Crellock heard the lock handle turn, and the door thrown
open so violently that it struck against the wall, but there
was no reply from the voices of frightened women.
“Do you hear? Milly—Julie! Why don’t you answer?” came
from above, and Crellock’s harsh breathing became like the
panting of some wild beast.
For a few moments there was absolute silence; then the
sound of stumbling, heavy steps, and Hallam came out on
to the landing.
“Steve!” he cried excitedly, perfectly sober now, “what is it?
What does it mean? They’ve gone!”
“I knew it,” cried Crellock with a furious cry. “I might have
seen it if I had not been a fool. Come down quick! They’ve
not gone far.”
Candle in hand, Hallam came staggering down the stairs
with his eyes staring and his face blotched with patches of
white.
“They’ve gone,” he stammered hoarsely. “What for? Where
have they gone?”
“Out into the dark night,” cried Crellock furiously. “There is
only one way that they could go, and we must have them
before they reach the town.”
“Town!” faltered Hallam; “town!” for in the horror of his
waking and the conscience hauntings of the moment, he
seemed to see two ghastly white faces looking up at him
from the black waters of the harbour.
“Yes, come along, follow me as quickly as you can,” roared
Crellock; and going swiftly through the dining-room he
crossed the verandah and dashed out into the thick
darkness that seemed to rise up as a protecting wall on
behalf of those whom he pursued.
Volume Four—Chapter Sixteen.
The Flight.
“I am so weak, my child,” sighed Mrs Hallam, “that my
heart fails me. What shall I do?”
Julia stood over her dressed for flight, and a chill of despair
seized her.
“Oh, mother, try—try,” she whispered.
“I am trying, Julie. I am fighting so hard, but you cannot
realise the step I am trying to take; you cannot see it, my
child, as it is spread before me.”
“Let us stay then,” whispered Julie, “and to-morrow I will
appeal to Sir Gordon to come to our help.”
“No,” said Mrs Hallam, firmly, as if the words of her child
had given her strength, “we can ask help of no one in such
a strait as this, Julie; the act must be mine and mine alone;
but now the time has come, my child, I feel that it is too
much.”
“Mother!” sobbed Julie, “that man horrifies me. You heard
all that my father said. I would sooner die than become his
wife.”
Mrs Hallam caught her arm with a sharp grip, and remained
silent for a few moments. “Yes,” she said at last, “and much
as I love you, my own, I would sooner see you dead than
married to such a man as he. You have given me the
courage I failed in, my darling. For myself, I would live and
bear until the end; but I am driven to it—I am driven to it.
Come.”
They were standing in the dark, and now for the time being
Mrs Hallam seemed transformed. Gathering her cloak about
her, she went quickly to the door and listened, and then
turned and whispered to Julia.
“Come at once,” she said. “Follow me down.” Julia drew a
long breath and followed her, trembling, the boards of the
lightly-built house cracking loudly as she passed quickly to
the stairs. And again in the silence and darkness these
cracked as they passed down.
In the hall Mrs Hallam hesitated for a moment, and then,
putting her lips to Julia’s ear:
“Stop!” she whispered.
Julia stood listening, and with her eyes strained towards
where a light shone beneath the ill-fitting study-door from
which, in the stillness, the heavy stertorous breathing of
Hallam could be heard. She could hear, too, the faint rustle
of Mrs Hallam’s dress as she paced along the hall; and as
Julia gazed in the direction she had taken, the light that
streamed from beneath, and some faint rays from the side,
showed indistinctly a misty figure which sank down on its
knees and remained for a few moments.
The silence was awful to the trembling girl, who could not
repress a faint cry as she heard a loud cough coming from
beyond the dining-room.
But she, too, drew her breath hard, and set her teeth as if
the nearness of her enemy provoked her to desperate
resistance, and she stood waiting there firmly, but
wondering the while whether they would be able to escape
or be stopped in the act of flight by Crellock, whom she
knew to be watching there.
She dare not call, though she felt that her mother was
again overcome by the terrors of the step they had resolved
to take, and the moments seemed interminable before
there was a change in the light beneath the door, and a
faint rustle mingled with the heavy breathing. Then her
hand was clasped by one like ice in its coldness, and, as if
repeating the prayer she had been uttering, Julia heard her
mother say in a faint whisper:
“It is for her sake—for hers alone.”
Julia drew her into the drawing-room as they had planned,
and closed the door. Then Mrs Hallam seemed to breathe
more freely.
“The weakness has passed,” she said softly. “We must lose
no time.”
They crossed the room carefully to where a dim light
showed the French window to be, and Mrs Hallam laid her
hand upon it firmly, and turned the fastening after slipping
the bolt.
“Keep a good heart, my darling,” she said. “You are not
afraid?”
“Not of our journey, mother,” said Julia in agitated tones;
“but of—a listener.”
“Hist!” whispered Mrs Hallam, drawing back; and the
window which she had opened swung to with a faint click,
as the firm pace of Crellock was heard coming along the
verandah; and as they stood there in the darkness they
could see the dim figure pass the window.
Had he stretched forth a hand, he would have felt the glass
door yield, and have entered and found them there; and,
knowing this, they stood listening to the beating of their
hearts till the figure passed on and they heard the step of
the self-constituted sentry grow faint on the other side of
the house.
“Julie, are you ready?”
“Yes, mother; let us go—anywhere, so that I may not see
that man again.”
Mrs Hallam uttered a sigh of relief, for her child’s words had
supplied her once more with the power that was failing.
“It is for her sake,” she muttered again. Then, in a low
whisper: “Quick! your hand. Come.” And they stepped out
into the verandah, drew the door to without daring to stop
to catch it, and the next minute they were threading their
way amongst the trees of the garden, and making for the
gate.
The darkness was now intense, and though the faint
twinkling of lights showed them the direction of the town,
they had not gone far before they found themselves astray
from the path, and after wandering here and there for a few
minutes, Mrs Hallam paused in dread, for she found that
there was now another enemy in her way upon which she
had not counted.
She spoke very calmly, though, as Julia uttered a gasp.
“The wind is rising,” she said, “and it will soon grow lighter.
Let us keep on.”
They walked on slowly and cautiously in and out among the
trees of what was, in the darkness, a complete wilderness.
At times they were struggling through bushes that impeded
their progress, and though time after time the track seemed
to be found, they were deceived. It was as if Nature were
fighting against them to keep them within reach of Hallam
and his friend, and, though they toiled on, a second hour
had elapsed and found them still astray.
But now, as they climbed a steep slope, the wind came with
a gust, the clouds were chased before it, there was the glint
of a star or two, and Mrs Hallam uttered an exclamation.
“There!” she cried, “to the left. I can see the lights now.”
Catching Julia’s hand more firmly, she hurried on, for the
night was now comparatively light, but neither uttered a
word of their thoughts as they gave a frightened glance
back at a dim object on the hill behind, for they awoke to
the fact that they had been wandering round and about the
hill and gully, returning on their steps, and were not five
hundred yards away from their starting-point.
At the end of a quarter of an hour the stars were out over
half the vault of heaven, and to their great joy the path was
found—the rough track leading over the unoccupied land to
the town.
“Courage! my child,” whispered Mrs Hallam; “another hour
or two and we shall be there.”
“I am trying to be brave, dear,” whispered back Julia as the
track descended into another gully; “but this feeling of
dread seems to chill me, and—oh! listen!”
Mrs Hallam stopped, and plainly enough behind them there
was the sound of bushes rustling; but the sound ceased
directly.
“Some animal—that is all,” said Mrs Hallam, and they
passed on.
Once more they heard the sound, and then, as they were
ascending a little eminence before descending another of
the undulations of the land, there came the quick beat of
feet, and mother and daughter had joined in a convulsive
grasp.
“We are followed,” panted Mrs Hallam. “We must hide.”
As she spoke they were on the summit of the slope, with
their figures against the sky-line to any one below, and in
proof of this there was a shout from a short distance below,
and a cry of “Stop!”
“Crellock!” muttered Mrs Hallam, and she glanced from side
to side for a place of concealment, but only to see that the
attempt to hide would be only folly.
“Can you run, Julie?” she whispered.
For answer Julia started off, and for about a hundred yards
they ran down the slope, and then stopped, panting. They
could make no further effort save that of facing their
pursuer, who dashed down to them breathless.
“A pretty foolish trick,” he cried. “Mercy I found you gone,
and came. What did you expect would become of you out
here in the night?”
“Loose my hand,” cried Julia angrily; “I will not come back.”
“Indeed, but you will, little wifie. There, it’s of no use to
struggle; you are mine, and must.”
“Julia, hold by me,” cried Mrs Hallam frantically. “Help!”
“Hah!”
That ejaculation was from Crellock, for as Mrs Hallam’s
appeal for help rang out amongst the trees of the gully into
which they had descended, there was the dull sound of a
heavy blow, and their assailant fell with a crash amongst
the low growth of scrub.
“This way,” said a familiar voice. “Do you want to join
Thisbe King?”
“Yes, yes,” cried Julia, sobbing now; “but how did you
know?”
“How did I know!” was the reply, half sadly, half laughingly.
“Oh, I have played the spy: waiting till you wanted help.”
“Christie Bayle!” wailed Mrs Hallam; “my friend in need.”
He did not answer. He hardly heard her words as Mrs
Hallam staggered on by his side, for two little hands were
clinging to his arm, Julia’s head was resting against him, as
she nestled closer and closer, and his heart beat madly, for
it seemed to him as if it was in his breast that Julia Hallam
would seek for safety in her time of need.
Volume Four—Chapter Seventeen.
In Sanctuary.
“Let them come if they dare, my dear,” said Thisbe stoutly.
“I’ve only waited for this. You know how I’ve never said
word against him, but have seen and borne everything.”
“Yes, yes,” sighed Mrs Hallam.
“For, I said to myself, the day will come when she will see
everything in its true light, and then—”
Thisbe said no more, but cut her sentence in half by closing
her lips more tightly than they had ever been closed before,
as, with a smile, she busied herself about Julia and her
mother.
“I was in a way last night,” she said cheerily, as she
straightened first one thing and then another in the modest
lodgings she had secured, “but I daren’t come away for fear
you might get here while I was looking for you. You don’t
know the relief I felt when Mr Bayle knocked at the door
with you two poor tired things. There, you needn’t say a
word, only be quiet and rest.”
Thisbe nodded from one to the other, and smiled as if there
was not a trouble in the world. Then she stood rolling up
her apron, and moistening her lips, as if there was
something she wanted to say but hesitated. At last she
went to Mrs Hallam’s side, and took hold of the sleeve of
her dress.
“Let me go and ask Mr Bayle to take berths for you on
board the first ship that’s going to sail, and get taken away
from this dreadful place.”
Mrs Hallam gazed at her wistfully, but did not answer for a
few moments.
“I must think, Thibs,” she said. “I must think; and now I
cannot, for I feel as if I am stunned.”
“Then lie down a bit, my dear Miss Milly. Do, dear. She
ought to, oughtn’t she, Miss Julie? There, I knew she would.
It’s to make her strong.”
It was as if old girlish days had come back, for Mrs Hallam
yielded with a sigh to the stronger will of the faithful old
servant, letting her lift and lay her down, and closing her
eyes with a weary sigh.
“Now I may go to Mr Bayle, mayn’t I?”
“No,” said Mrs Hallam sternly.
“Then to Sir Gordon, and ask him to help us?”
“No,” said Mrs Hallam again; “I must work alone in this—
and I will.”
She closed her eyes, and in a few minutes seemed to have
dropped off asleep, when Thisbe signed to Julia to
accompany her out of the room.
“Don’t you fret and trouble yourself, my darling,” she
whispered. “I’ll take care no one comes and troubles you.
She’s worn out with suffering, and no doctor would do her
good, or we’d soon have the best in the town. What she
wants is rest and peace, and your dear loving hands to hold
her. If anything will ease her that’s it.”
She kissed Julia, and the next moment the girl’s arms were
clasped about her neck, and she sobbed upon her breast.
“It’s so terrible,” she cried. “I can’t bear it! I can’t bear it! I
tried so hard to love him, but—but—”
“An angel with wings couldn’t have loved such a father as
that, my dear.”
“Thibs!”
“Well, there, then, I won’t say much, my darling; but don’t
you fret. You’ve both done quite right, for there’s a pynte
beyond which no one can go.”
“But if we could win him back to—”
“Make you marry that man Crellock! Oh, my darling, there’s
no winning him back. I said nothing and stood by you both
to let you try, and I was ready to forgive everything; but
oh, my pet! I knew how bad it all was from the very first.”
“No, no, Thibs, you didn’t think him guilty when he was sent
out here.”
“Think, my dear! No: I knew it, and so did Sir Gordon and
Mr Bayle, but for her sake they let her go on believing in
him. Oh! my dear, only that there’s you here, I want to
know why such a man was ever allowed to live.”
“Thibs, he is my father,” cried Julia angrily.
“Yes, my dear, and there’s no changing it, much as I’ve
thought about it.”
Julia stood thinking.
“I shall go to him,” she said at last, “with you, and tell him
why we have left him. I feel, Thibs, as if I must ask him to
forgive me, for I am his child.”
“You wait a bit, my dear, and then talk about forgiveness
by-and-by. You’ve got to stay with your poor mother now.
Why, if you left her on such an errand as that, what would
happen if he kept you, and wouldn’t let you come back?”
Julia’s eyes dilated, and her careworn face grew paler.
“He would not do that.”
“He and that Crellock would do anything, I believe. There,
you can’t do that now. You’ve got to sit and watch by her.”
“Julia!” came in an excited voice from the next room.
“There, what did I tell you, my dear?” said Thisbe; and she
hurried Julia back and closed the door.
“They’ll go back and forgive him if he only comes and begs
them to, and he’ll finish breaking her heart,” said Thisbe, as
she went down. “Oh, there never was anything so dreadful
as a woman’s weakness when once she has loved a man.
But go back they shall not if I can help it, and what to do
for the best I don’t know.”
She went into the little sitting-room, seated herself, and
began rolling her apron up tightly, as she rocked herself to
and fro, and all the time kept on biting her lips.
“I daren’t,” she said. “She would never forgive me if she
knew. No, I couldn’t.”
She went on rocking herself to and fro.
“I will—I will do it. It’s right, for it’s to save them; it’s to
save her life, poor dear, and my darling from misery.”
She started from her chair, wringing her hands, and with
her face convulsed, ending by falling on her knees with
clasped hands.
“Oh, please God, no,” she cried, “don’t—don’t suffer that—
that darling child to be dragged down to such a fate. I
couldn’t bear it. I’d sooner die! For ever and ever. Amen.”
She sobbed as she crouched lower and lower, suffering an
agony of spirit greater than had ever before fallen to her
lot, and then rose, calm and composed, to wipe her eyes.
“I’ll do it, and if it’s wicked may I be forgiven. I can’t bear
it, and there’s only that before he puts the last straw on.”
There was a loud tap at the door just then, evidently given
by a hard set of knuckles.
“It’s them!” cried Thisbe excitedly; “it’s them!” The door
was locked and bolted, and she glanced round the room as
if in search of a weapon. Then going to the window, she
looked sidewise through the panes, and her hard, angry
face softened a little, and she opened the window.
“How did you know I was wanting you to come?”
Tom Porter’s hard brown face lit up with delight. “Was you?”
he cried; “was you, Thisbe? Lor’! how nice it looks to see
you in a little house like this, and me coming to the door;
but you might let me in. Are you all alone?”
“Don’t you get running your thick head up against a wall,
Tom Porter, or you’ll hurt it. And now, look here, don’t you
get smirking at me again in that way, or off you go about
your business, and I’ll never look at you again.”
“But Thisbe, my dear, I only—”
“Don’t only, then,” she said, in a fierce whisper; “and don’t
growl like that, or you’ll frighten them as is upstairs into
thinking it’s some one else.”
“All right, my lass; all right. Only you are very hard on a
man. You was hard at King’s Castor, you was harder up at
Clerkenwell, while now we’re out here rocks is padded
bulkheads to you.”
“I can’t help it, Tom; I’m in trouble,” said Thisbe more
gently.
“Are you, my lass? Well, let me pilot you out.”
“Yes, I think you shall,” she said, “I wanted you to come.”
“Now, that’s pleasant,” said Tom Porter, smiling; “and it
does me good, for the way in which I wants to help you,
Thisbe, is a wonder even to me.”
“Oh, yes, I know,” she said grimly. “Now then, why did you
come?”
“You said you wanted me.”
“Yes; but tell me first why you came.”
“The Admiral sent me to say that he was waiting for the
missus’s commands, and might he come down and see her
on very partic’lar business? He couldn’t write, his hand’s all
a shake, and he ain’t been asleep all night.”
“Tell him, and tell Mr Bayle, too, that my mistress begs that
she may be left alone for the present. She says she will
send to them if she wants their help.”
“Right it is,” said Tom Porter. “Now then, what did you want
along o’ me?”
Thisbe’s face hardened and then grew convulsed, and the
tears sprang to her eyes. Then it seemed to harden up
again, and she took hold of Tom Porter’s collar and
whispered to him quickly.
“Phe-ew!” whistled Sir Gordon’s man.
She went on whispering in an excited way.
“Yes, I understand,” he said.
She whispered to him again more earnestly than ever.
“Yes. Not tell a soul—and only if—”
“Yes.”
“Only if—”
“Yes, yes,” whispered Thisbe. “Mind, I depend upon you.”
“If Tom Porter’s a living soul,” he replied, “it’s done. But you
do mean it?”
“I mean it,” said Thisbe King. “Now go.”
“One moment, my lass,” he said. “I’ve been very humble,
and humble I am; but when this trouble’s over and smooth
water comes, will you?”
Thisbe did not answer for a few moments, and then it was
in a softened voice.
“Tom Porter,” she said, “there’s one upstairs half dead with
misery, and her darling child suffering more than words can
tell. My poor heart’s full of them; don’t ask me now.”
Tom Porter gave his lips a smart slap and hurried down the
street, while Thisbe closed the window and went back to her
chair, to rock herself to and fro again, with her hands busily
rolling and unrolling her apron.
“I’ve done it,” she said; “but it all rests on him. It’s his own
doing.”
Then, after a pause:
“How long will it be before they find out where we are? Not
long. Hah!”
Thisbe King passed her hands up and down her bare brawny
arms, and her face tightened for the encounter which she
felt must come before long.
Volume Four—Chapter Eighteen.
The Blow Falls.
It was close upon evening before the trouble Thisbe
expected came. Tom Porter had been again, tapped at the
door, and when Thisbe went to the window he had contorted
his face in the most horrible manner, closing his left eye,
and then walked off without a word.
Thisbe watched till he was out of sight, and then returned to
her chair.
“He’s to be trusted,” she said to herself. “It’s a pity he wants
to marry me. We’re much better as we are; and who knows
but what he might turn wild? There’s only one thing in his
favour, he ain’t a handsome man.”
Now Tom Porter at fifty looked to be about the last person
in the world to turn wild, but Thisbe’s experiences had done
much to harden her virgin heart.
At least a dozen times over she had slipped off her shoes
and ascended the stairs to find that, utterly exhausted, Mrs
Hallam and Julia were sleeping heavily, the latter on a chair,
with her arms clasped about her mother’s neck.
“Poor dears!” said Thisbe, as she descended; “I daren’t
wake them, but they ought to have a cup of tea.”
“Ah,” she exclaimed softly, “what would she say? I shall
never dare to look her in the face again.”
At last the trouble came.
“I knew it,” said Thisbe, as she heard the steps at the door.
“He was bound to find us. Yes, they’re both there. Well, it’s
his own work and not mine. What shall I do?”
She rose from her chair, looking very resolute. “I’ll face
them bold. It’s the only way.”
She heard the murmur of men’s voices, and then there was
a rap at the door given with the handle of a whip. She went
to the door, unfastened and threw it open.
“What is it?” she said.
Hallam and Crellock were on the threshold, and the latter
exclaimed, as soon as he saw her:
“I thought so.”
They stepped in quickly, and Thisbe’s lips tightened as she
was forced to back before them, and the door swung to.
“Where is your mistress?” said Hallam sharply.
“Asleep. Worn out and ill.”
“Where’s my daughter?”
“With her mother: upstairs.”
“I’ll soon have an end of this fooling,” he exclaimed; and as
Thisbe stood with her arms folded, she seemed to see a
flash of the old look she remembered—the look she hated—
when they were at Castor years before.
Hallam threw open the door at the foot of the narrow
staircase, while Crellock seated himself astride a chair with
his hat on and beat his boot with his whip.
“Millicent! Julie!” cried Hallam fiercely, and there were
footsteps heard above, for the arrival had awakened those
who slept. “Come down at once.”
He let the door swing to and began to pace the little room,
muttering to himself, and evidently furious with rage at his
wife’s desertion.
Crellock watched him from the corner of his eyes, and from
time to time unconsciously applied his hand to a great
discolouration on the cheek. He was evidently quite
satisfied, for Hallam needed no egging on to the task, and
he felt that this episode would hasten his marriage.
“Are you coming?” cried Hallam, after a few minutes, and as
he flung back the door, that of the bedroom was heard to
open, and Mrs Hallam and Julia came down, both very pale,
but with a firmness in their countenances that sent a thrill
of joy through Thisbe.
“There you are then,” cried Hallam, as they stood before
him. “Ah! I’ve a good mind to—”
He raised his hand and made a feint as if to strike the pale,
suffering woman. With a cry of horror, Julia flung herself
between them, her eyes flashing, her dread gone, and in its
place, indignant horror sweeping away the last feeling of
pity and compunction for the brutalised man to whom she
owed her birth.
“Now then,” cried Hallam. “You’ve both had your fool’s game
out, so put on your bonnets and come home.” Mrs Hallam
passed her hand round Julia and remained silent.
“Do you hear?” cried Hallam. “I say, put on your things and
come home. As for you, madam, you shall have a home of
your own, and a husband, before you know where you are.
Come; stir!” he cried, with a stamp. “This is my home,” said
Mrs Hallam, sternly. “What!”
“Robert Hallam, the last thread that bound me to you is
broken,” she continued, in a calm, judicial voice. “We are
separated for ever.”
“You’re mad,” cried Hallam, with a laugh. “Come, no
nonsense, ma’am! Don’t make a scene, for I’m not in the
humour to put up with much. Come out of this house or—”
He made a step or two towards the door, for Thisbe had
thrown it open, having seen Bayle pass the window with Sir
Gordon. Then he seized the door to fling it in their faces;
but Thisbe held it firmly, and they walked in, Hallam himself
giving way.
“Coward!” snarled Crellock in his ear, as he started up, whip
in hand.
“Mrs Hallam,” said Sir Gordon, “you must forgive this
intrusion. I am sure we are wanted here.”
“Wanted here!” cried Hallam savagely; “no, you are not
wanted here. I’ll have no more interferences from such as
you; you’ve both been the curse of my life.”
Sir Gordon turned upon him with a calm look of disgust and
contempt, which at another time would have made him
quail; but, fevered with brandy as he was, the effect was to
make him more beside himself.
“As you are here, both of you, let me tell you this: that I
don’t kick you out because one of you is a weak, doddering
old idiot, the other—oh, his cloth must protect Mr Bayle.
Now what do you want?”
“Be calm, Julia,” whispered Bayle. “No harm shall befall
either of you.”
Crellock advanced menacingly, but Sir Gordon interposed.
“Mrs Hallam, as your father’s old friend, I must interfere for
your protection now.”
“Must you?” cried Hallam fiercely, “then I tell you that you
won’t. This is my house, taken by my wife. That is my wife.
That is my child, and in a few days she will be the wife of
this gentleman, my oldest friend. Now go. Millicent—Julie—
get on your things, and come, or, by all that’s holy, we’ll
drag you through the streets.”
Julia clung to Bayle, and turned her flushed face to him as if
asking help; while, with a look of calm contempt, he patted
the hand he held, and glanced at Mrs Hallam, for something
seemed to warn him that the crisis had arrived.
“I have told you, Robert Hallam,” she said, in a calm, firm
voice, that grew in strength as she went on, “that from this
hour we are separated, never to be man and wife again. I
clung to you in all a woman’s proud faith in her husband. I
loved you as dearly as woman could love. When you were
condemned of all, I defended you, and believed you
honest.”
“Bah!” he exclaimed; “enough of this!” and he took a step
forward, but quailed before her gaze.
“You crushed my love. You made me your wretched
innocent tool and slave when you brought me here, and at
last you brutally told me all the cruel truth. Even then,
heartbroken, I clung to you, and suffered in silence. God
knows how I tried to bring you to penitence and a better
life. I forgave all for the sake of our child; and in my love
for her I would have gone on bearing all.”
“Have you nearly done?” he said mockingly.
“Nearly,” she said, in the same firm, clear tones; and she
seemed to tower above him, pale and noble of aspect, while
he, drink-brutalised and blotched, seemed to shrink.
“I say I would have borne everything, even if you had
beaten me like a dog. But when—oh, my God, judge
between us and forgive me if I have done wrong!—when I
am called upon to see my innocent child dragged down by
you to the fate of being the wife of the villain who has been
your partner in all your crimes, my soul revolts, and I say—
from this hour all between us is at an end.”
“And I say,” he yelled, “that you are my wife, this my child,
and you shall obey me. Come; I am master here.”
He made a snatch at her arm, but she raised it before him,
with outstretched palm, and her voice rang out with a cry
that made him shrink and cower.
“Stop!”
There was a moment’s utter silence, broken by the softly
heard tramp of feet.
“Husband no longer, father of my child no more. Robert
Hallam, you are my convict servant! I discharge you. Leave
this house!”
Hallam took a step back, literally stunned by the words of
the outraged woman, who for so long a time had been his
slave, while Bayle uttered a long sighing sound as if relieved
of some terrible weight.
For a time no one spoke, but all turned from gazing on the
prominent figure of that group, to Hallam, who stood
clenching and unclenching his hands, and gasping as if
trying to recover from the shock he had received.
He essayed to speak as he glared at Mrs Hallam, and
scowled at her as if each look were an arrow to wound and
bring her to his feet humbled and appealing as of old; but
the arrows glanced from the armour of indignant maternal
love with which she was clothed; and, drawn up to her full
height, scornful and defiant as she seemed, her look
absolutely made him quail.
Tramp—tramp—tramp—tramp.
The regular march of disciplined men coming nearer and
nearer, but heard by none within that room, as Crellock,
with a coarse laugh, bent forward, and whispered in his
companion’s ear:
“Why, man, are you going to submit to this?”
“No!” roared Hallam, as if his gang-companion’s words had
broken a spell. “No! The woman’s mad! Julia, you are my
child. Come here!”
Julia met the eyes that were fixed fiercely upon her, and
stepped forward.
Bayle tried to arrest her, but she raised her hand to keep
him back, and then placed it on her father’s arm, trembling
and looking white. Then she reached up, and kissed him
solemnly upon the cheek.
“There, gentlemen,” he cried triumphantly. “You see. Now,
wife—my wife, come to your convict servant—come—home.”
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebookluna.com

More Related Content

Similar to (eBook PDF) Introduction to Programming with Java: A Problem Solving Approach 3rd Edition (20)

PDF
(eTextbook PDF) for Starting Out with Java: From Control Structures through O...
gandheassoah
 
PDF
Pearson.Java.How.To.Program.late.objects.10th.Edition.www.EBooksWorld.ir.pdf
fareedullah211398
 
PDF
java-language-programação.2-PDF Room.pdf
carloseduardogonalve36
 
PDF
Download full ebook of Java Cookbook Ian F Darwin Darwin Ian F instant downlo...
tvuxidu670
 
PDF
Download full ebook of Programming With Java Edet Theophilus instant download...
noyzdapat39
 
PDF
Java programming-language-handbook
Philip Solomon
 
PDF
(eBook PDF) Starting Out with Java: From Control Structures through Objects, ...
dsqdewaets644
 
PDF
Java Foundations Introduction To Program Design And Data Structures 2nd Editi...
eestissingar
 
PDF
Java Complete Reference Fifth Edition
umavanth
 
PDF
Objectoriented Programming And Java 2nd Ed Danny C C Poo Derek Beng Kee Kiong...
orianzotto3i
 
PDF
[FREE PDF sample] Object Oriented Programming and Java Second Edition Danny P...
ackeylocusr5
 
PDF
Essential Java For Scientists And Engineers 1st Brian D Hahn
yralabasah
 
PPTX
Java programmingjsjdjdjdjdjdjdjdjdiidiei
rajputtejaswa12
 
PDF
Java Programming.pdf
IthagoniShirisha
 
PDF
Java How To Program Early Objects Eleventh Edition Deitel Harvey M Deitel
yehlewiste2y
 
PPT
Java
Prabhat gangwar
 
PPT
Chapter 1 java
ahmed abugharsa
 
PDF
Mastering Java: A Beginner's Guide 1st Edition Sufyan Bin Uzayr
wilkserronlc
 
PDF
M251_Meeting 1(M251_Meeting 1_updated.pdf)
hossamghareb681
 
PPTX
chapter 1-overview of java programming.pptx
nafsigenet
 
(eTextbook PDF) for Starting Out with Java: From Control Structures through O...
gandheassoah
 
Pearson.Java.How.To.Program.late.objects.10th.Edition.www.EBooksWorld.ir.pdf
fareedullah211398
 
java-language-programação.2-PDF Room.pdf
carloseduardogonalve36
 
Download full ebook of Java Cookbook Ian F Darwin Darwin Ian F instant downlo...
tvuxidu670
 
Download full ebook of Programming With Java Edet Theophilus instant download...
noyzdapat39
 
Java programming-language-handbook
Philip Solomon
 
(eBook PDF) Starting Out with Java: From Control Structures through Objects, ...
dsqdewaets644
 
Java Foundations Introduction To Program Design And Data Structures 2nd Editi...
eestissingar
 
Java Complete Reference Fifth Edition
umavanth
 
Objectoriented Programming And Java 2nd Ed Danny C C Poo Derek Beng Kee Kiong...
orianzotto3i
 
[FREE PDF sample] Object Oriented Programming and Java Second Edition Danny P...
ackeylocusr5
 
Essential Java For Scientists And Engineers 1st Brian D Hahn
yralabasah
 
Java programmingjsjdjdjdjdjdjdjdjdiidiei
rajputtejaswa12
 
Java Programming.pdf
IthagoniShirisha
 
Java How To Program Early Objects Eleventh Edition Deitel Harvey M Deitel
yehlewiste2y
 
Chapter 1 java
ahmed abugharsa
 
Mastering Java: A Beginner's Guide 1st Edition Sufyan Bin Uzayr
wilkserronlc
 
M251_Meeting 1(M251_Meeting 1_updated.pdf)
hossamghareb681
 
chapter 1-overview of java programming.pptx
nafsigenet
 

Recently uploaded (20)

PPTX
ENGLISH -PPT- Week1 Quarter1 -day-1.pptx
garcialhavz
 
PDF
Rapid Mathematics Assessment Score sheet for all Grade levels
DessaCletSantos
 
PDF
Supply Chain Security A Comprehensive Approach 1st Edition Arthur G. Arway
rxgnika452
 
DOCX
MUSIC AND ARTS 5 DLL MATATAG LESSON EXEMPLAR QUARTER 1_Q1_W1.docx
DianaValiente5
 
PPTX
Tanja Vujicic - PISA for Schools contact Info
EduSkills OECD
 
PDF
VCE Literature Section A Exam Response Guide
jpinnuck
 
PPTX
How to Manage Wins & Losses in Odoo 18 CRM
Celine George
 
PPTX
Elo the Hero is an story about a young boy who became hero.
TeacherEmily1
 
PPTX
Urban Hierarchy and Service Provisions.pptx
Islamic University of Bangladesh
 
PDF
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
PDF
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
PDF
Learning Styles Inventory for Senior High School Students
Thelma Villaflores
 
DOCX
DLL english grade five goof for one week
FlordelynGonzales1
 
PPTX
How to use _name_search() method in Odoo 18
Celine George
 
PPTX
Aerobic and Anaerobic respiration and CPR.pptx
Olivier Rochester
 
PPTX
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
PPTX
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
 
DOCX
ANNOTATION on objective 10 on pmes 2022-2025
joviejanesegundo1
 
PPTX
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
PPTX
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
ENGLISH -PPT- Week1 Quarter1 -day-1.pptx
garcialhavz
 
Rapid Mathematics Assessment Score sheet for all Grade levels
DessaCletSantos
 
Supply Chain Security A Comprehensive Approach 1st Edition Arthur G. Arway
rxgnika452
 
MUSIC AND ARTS 5 DLL MATATAG LESSON EXEMPLAR QUARTER 1_Q1_W1.docx
DianaValiente5
 
Tanja Vujicic - PISA for Schools contact Info
EduSkills OECD
 
VCE Literature Section A Exam Response Guide
jpinnuck
 
How to Manage Wins & Losses in Odoo 18 CRM
Celine George
 
Elo the Hero is an story about a young boy who became hero.
TeacherEmily1
 
Urban Hierarchy and Service Provisions.pptx
Islamic University of Bangladesh
 
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
Learning Styles Inventory for Senior High School Students
Thelma Villaflores
 
DLL english grade five goof for one week
FlordelynGonzales1
 
How to use _name_search() method in Odoo 18
Celine George
 
Aerobic and Anaerobic respiration and CPR.pptx
Olivier Rochester
 
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
 
ANNOTATION on objective 10 on pmes 2022-2025
joviejanesegundo1
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
Ad

(eBook PDF) Introduction to Programming with Java: A Problem Solving Approach 3rd Edition

  • 1. (eBook PDF) Introduction to Programming with Java: A Problem Solving Approach 3rd Edition download https://ebookluna.com/product/ebook-pdf-introduction-to- programming-with-java-a-problem-solving-approach-3rd-edition/ Download more ebook from https://ebookluna.com
  • 2. John Dean Park University Raymond Dean University of Kansas JAVA WITH A Problem Solving Approach Introduction to Programming dea75768_fm_i-xxxviii.indd 1 4/30/20 11:54 AM
  • 3. 12.10. Empty Statement 552 12.11. Using break to Exit from a Loop 554 12.12. for Loop Header Details 555 12.13. Enumerated Types 557 12.14. forEach Method, Lambda Expressions, Method References, and Streams 564 12.15. Hexadecimal, Octal, and Binary Numbers 573 12.16. GUI Track: Unicode (Optional) 574 12.17. Introduction to GridWorld Case Study (Optional) 579 CHAPTER 13 Aggregation, Composition, and Inheritance 591 13.1. Introduction 592 13.2. Composition and Aggregation 592 13.3. Inheritance Overview 599 13.4. Implementation of a Person/Employee/ FullTime Hierarchy 603 13.5. Constructors in a Subclass 605 13.6. Method Overriding 606 13.7. Using the Person/Employee/FullTime Hierarchy 609 13.8. The final Access Modifier 610 13.9. Using Inheritance with Aggregation and Composition 610 13.10. Design Practice with Card Game Example 613 13.11. GridWorld Case Study Extensions (Optional) 619 13.12. Problem Solving with Association Classes (Optional) 626 CHAPTER 14 Inheritance and Polymorphism 637 14.1. Introduction 638 14.2. The Object Class and Automatic Type Promotion 638 14.3. The equals Method 639 14.4. The toString Method 643 14.5. Polymorphism and Dynamic Binding 648 14.6. Assignments When the Two Sides’ Classes Are Different 653 14.7. Polymorphism with Arrays 654 14.8. abstract Methods and Classes 660 14.9. Interfaces 663 14.10. The protected Access Modifier 673 14.11. GUI Track: Three-Dimensional Graphics (Optional) 677 CHAPTER 15 Exception Handling 691 15.1. Introduction 692 15.2. Overview of Exceptions and Exception Messages 692 15.3. Using try and catch Blocks to Handle “Dangerous” Method Calls 693 15.4. Line Plot Example 695 15.5. try Block Details 699 15.6. Two Categories of Exceptions—Checked and Unchecked 700 15.7. Unchecked Exceptions 702 15.8. Checked Exceptions 705 15.9. Generic catch Block with Exception Class 708 15.10. Multiple catch Blocks and Multiple Exceptions per Block 712 15.11. Understanding Exception Messages 714 15.12. Using a throws Clause to Postpone the catch 718 15.13. Automatic Cleanup Using Try-With- Resources 720 15.14. GUI Track: Line Plot Example Revisited (Optional) 722 CHAPTER 16 Files, Buffers, Channels, and Paths 735 16.1. Introduction 736 16.2. Simple Text-File Example: HTML File Generator 737 16.3. A Website Reader 741 16.4. Object File I/O 743 16.5. Character Sets and File-Access Options 748 16.6. Buffered Text File I/O 749 16.7. Primitive Buffers with Random Access 752 16.8. Channel I/O and Memory-Mapped Files 760 viii Contents dea75768_fm_i-xxxviii.indd 8 4/30/20 11:54 AM
  • 4. 16.9. Path, Whole-File, and Directory Operations 767 16.10. Walking a Directory Tree 769 16.11. GUI Track: Final Iteration of Problem Solving with CRC Cards (Optional) 775 CHAPTER 17 GUI Programming Basics 787 17.1. Introduction 788 17.2. SimpleWindow Program 791 17.3. Stage and Scene 794 17.4. JavaFX Components 796 17.5. Label Control 797 17.6. TextField Control 799 17.7. Greeting Program 801 17.8. Event Handling 805 17.9. Property Binding 809 17.10. JavaFX CSS 812 17.11. Scene Graph Inheritance 818 17.12. Style Sheets and Cascading 821 17.13. Button Control and FactorialButton Program 826 17.14. Distinguishing Between Multiple Events 832 17.15. Colors 834 17.16. ColorChooser Program 838 CHAPTER 18 GUI Programming—Layout Panes 849 18.1. Introduction 849 18.2. Layout Panes 851 18.3. FlowPane and GridPane—Competing Layout Philosophies 853 18.4. VBox Program with Two Stages and an Image File 858 18.5. BorderPane 867 18.6. TilePane and TextFlow Containers 872 18.7. TicTacToe Program 878 18.8. Embedded Panes, HBox, and MathCalculator Program 882 18.9. Plain Pane Container and Component Positioning 889 CHAPTER 19 GUI Programming—Additional GUI Components, Additional Event Handlers, Animation 896 19.1. Introduction 897 19.2. User Interface Design 897 19.3. TextArea Control 898 19.4. CheckBox and RadioButton Controls 903 19.5. ComboBox Control 909 19.6. Job Application Program 913 19.7. ScrollPane and Menu Classes 918 19.8. Images and Mouse Events 922 19.9. Lunar Eclipse Program with Circle, RadialGradient, and Slider 928 19.10. Animation 933 Appendices Appendix 1 ASCII Character Set 943 Appendix 2 Operator Precedence 945 Appendix 3 Java Keywords and Other Reserved Words 947 Appendix 4 Packages and Modules 951 Appendix 5 Java Coding-Style Conventions 963 Appendix 6 Javadoc with Tags 975 Appendix 7 UML Diagrams 980 Appendix 8 Number Systems and Conversions Between Them 986 Additional Online Material Chapter S6 Writing Methods in a Non-Object- Oriented Environment Chapter S9 Arrays in a Non-Object-Oriented Environment Chapter S17 GUI Programming Basics Chapter S18 GUI Programming—Component Layout, Additional GUI Components Appendix 9 Multithreading Index 990 Contents ix dea75768_fm_i-xxxviii.indd 9 5/12/20 1:41 PM
  • 5. x In this book, we lead you on a journey into the fun and exciting world of computer programming. Through- out your journey, we’ll provide you with lots of problem-solving practice. After all, good programmers need to be good problem solvers. We’ll show you how to implement your problem solutions with Java programs. We provide a plethora of examples, some short and focused on a single concept, some longer and more “real world.” We present the material in a conversational, easy-to-follow manner aimed at making your journey a pleasant one. When you’re done with the book, you should be a proficient Java programmer. Our textbook targets a wide range of readers. Primarily, it targets students in a standard college-level “Introduction to Programming” course or course sequence where no prerequisite programming experience is assumed. We have included the topics recommended by the College Board for high school students studying for advanced placement (AP) in computer science. So this text should be good for those students as well. In addition to targeting students with no prerequisite programming experience, our textbook targets industry practitioners and college-level students who have some programming experience and want to learn Java. This second set of readers can skip the early chapters on general programming concepts and focus on the features of Java that differ from the languages that they already know. In particular, because C++ and Java are similar, readers with a C++ background should be able to cover the textbook in a single three-credit-hour course. (But we should reiterate for those of you with no programming experience: No prerequisite programming experience is required in order to use this text.) Finally, our textbook targets those who are learning Java on their own, outside of a classroom environ- ment. This third set of readers should read the entire textbook at a pace determined on a case-by-case basis. What’s New in This Edition? The changes in this edition are big and small. Big changes include new chapters, reorganized chapter sec- tions, new programming constructs, new program examples, and new exercises. Smaller changes include updating explanations and anecdotes. We’ve combed the entire book for opportunities to improve the book’s clarity and readability. The following list highlights the more significant changes that we’ve made to this edition. ∙ Introductory Chapter To keep up with the computer industry’s growth, we’ve made quite a few changes to Chapter 1, such as updating the information in the computer hardware and Java history sections. ∙ Switching Constructs Java 12 and Java 13 made improvements to the venerable switch statement, and this edition describes those improvements. We use the new switching techniques (multiple comma-­ separated case constants and no break statements) for programs throughout the book. And we use switch statements versus switch expressions according to what the problem calls for. If you’re a fan of the old-style switch statement, no worries, we provide a description early on which will help you with legacy code. Preface dea75768_fm_i-xxxviii.indd 10 4/30/20 11:54 AM
  • 6. Preface xi ∙ Local Variable Type Inferencing Java 10 introduced the ability to use var as a type (rather than int, double, etc.) for a local variable declaration where the declaration is part of an initialization. We describe the new syntax, but for self- documentation reasons, we stick with traditional explicit type declarations for the most part. ∙ Name Change for Static Variables and Static Methods The powers that be (the Oracle documentation folks) now use the terms static variable and static method for what used to be known as class variable and class method, so we’ve updated accordingly. ∙ Miscellaneous Java API Library Updates With the new Java releases since the second edition, there have been quite a few updates to the Java API library. We’ve updated our discussions and programs with new API method and constructor calls when appropriate. Most of our new API content can be found in our GUI coverage, but there are other API changes sprinkled throughout the book. For example, with Java’s deprecation of the wrapper class constructors, we’ve refactored our programs to rely on the wrapper classes’ valueOf methods. ∙ New Section—forEach Method and Streams We introduce the forEach method as a simple alternative to the for-each loop in the context of an ArrayList. We then use the forEach method in the context of streams, where it really shines. We describe streams in depth, with their exciting potential to take advantage of parallel processing to improve a program’s efficiency. ∙ Lambda Expressions and Method References Lambda expressions and method references are techniques that allow you to implement the function- ality of a method so you can use it as an argument in a method call. We first present lambda expres- sions and method references as arguments for a forEach method call. Later, we use lambda expressions and method references extensively to help with the GUI programs. ∙ Interfaces with Static Methods and Default Methods We’ve rewritten Chapter 14’s section on interfaces to include a discussion of static methods and default methods. Oracle added them to interfaces because they support an interface’s ability to imple- ment multiple inheritance effectively. ∙ End-of-Chapter GUI Sections We’ve rewritten all of our end-of-chapter GUI sections to take advantage of Java’s newer GUI constructs. ∙ Three New Chapters—JavaFX In this book’s second edition, we used the AWT and Swing platforms for our two GUI chapters. This third edition moves those chapters to the book’s website. We provide three new chapters in the main body of the book that describe GUI programming using the JavaFX platform. As part of that presenta- tion, you’ll learn how to format your programs using JavaFX CSS properties. ∙ New Appendix—Modules In Appendix 4, we introduce modules, which allow you to group together packages. Modules make it easier to organize and share classes for different programming needs. They are used to facilitate the configuration of Java software for diverse hardware and software platforms. dea75768_fm_i-xxxviii.indd 11 5/10/20 8:49 PM
  • 7. xii Preface ∙ New Exercises We have substantially changed most of the exercises and altered almost all of them in some way. As before, we provide exercise solutions on the password-protected instructor’s portion of the book’s website. Compliant with the College Board’s AP Computer Science A Curriculum We have put a great deal of effort into ensuring that this textbook is compliant with the College Board’s Advanced Placement (AP) Computer Science A curriculum content. It follows all the AP Computer Science A guidelines. As such, it appears on the College Board’s approved textbook list at https://apcentral.collegeboard.org/courses/ap-computer-science-a/course-audit. Textbook Cornerstone #1: Problem Solving Being able to solve problems is a critical skill that all programmers must possess. We teach programmatic problem solving by emphasizing two of its key elements—algorithm development and program design. Emphasis on Algorithm Development In Chapter 2, we immerse readers into algorithm development by using pseudocode for the algorithm examples instead of Java. In using pseudocode, students are able to work through nontrivial problems on their own without getting bogged down in Java syntax—no need to worry about class headings, semico- lons, braces, and so on.1 Working through nontrivial problems enables students to gain an early apprecia- tion for creativity, logic, and organization. Without that appreciation, Java students tend to learn Java syntax with a rote-memory attitude. But with that appreciation, students tend to learn Java syntax more quickly and effectively because they have a motivational basis for learning it. In addition, they are able to handle nontrivial Java homework assignments fairly early because they have prior experience with simi- larly nontrivial pseudocode homework assignments. In Chapter 3 and in later chapters, we rely primarily on Java for algorithm-development examples. But for the more involved problems, we sometimes use high-level pseudocode to describe first-cut proposed solutions. Using pseudocode enables readers to bypass syntax details and focus on the algorithm portion of the solution. Emphasis on Program Design Problem solving is more than just developing an algorithm. It also involves figuring out the best imple- mentation for the algorithm. That’s program design. Program design is extremely important, and that’s why we spend so much time on it. Frequently, we explain the thought processes that a person might go through when coming up with a solution. For example, we explain how to choose between different loop types, how to split up a method into multiple methods, how to decide on appropriate classes, how to 1 Inevitably, we use a particular style for our pseudocode, but we repeatedly emphasize that other pseudocode styles are fine so long as they convey the intended meaning. Our pseudocode style is a combination of free-form description for high-level tasks and more specific commands for low-level tasks. We’ve chosen a pseudocode style that is intuitive, to welcome new programmers, and struc- tured, to accommodate program logic. dea75768_fm_i-xxxviii.indd 12 4/30/20 11:54 AM
  • 8. Preface xiii choose between instance and static members, and how to determine class relationships using inheritance and composition. We challenge students to find the most elegant implementations for a particular task. We devote a whole chapter to program design—Chapter 8, “Software Engineering.” In that chapter, we provide an in-depth look at coding-style conventions and documentation for programmers and users. We discuss design strategies like separation of concerns, modularization, and encapsulation. Also in the chapter, we describe alternative design strategies—top-down, bottom-up, case-based, and iterative enhancement. Problem-Solving Sections We often address problem solving (algorithm development and program design) in the natural flow of explaining concepts. But we also cover problem solving in sections that are wholly devoted to it. In each problem-solving section, we present a situation that contains an unresolved problem. In coming up with a solution for the problem, we try to mimic the real-world problem-solving experience by using an iterative design strategy. We present a first-cut solution, analyze the solution, and then discuss possible improve- ments to it. We use a conversational trial-and-error format (e.g., “What type of layout manager should we use? We first tried the GridLayout manager. That works OK, but not great. Let’s now try the BorderLayout manager.”). This casual tone sets the student at ease by conveying the message that it is normal, and in fact expected, that a programmer will need to work through a problem multiple times before finding the best solution. Additional Problem-Solving Mechanisms We include problem-solving examples and problem-solving advice throughout the text (not just in Chapter 2, Chapter 8, and the problem-solving sections). As a point of emphasis, we insert a problem- solving box, with an icon and a succinct tip, next to the text that contains the problem-solving example and/or advice. We are strong believers in learning by example. As such, our textbook contains a multitude of com- plete program examples. Readers are encouraged to use our programs as recipes for solving similar pro- grams on their own. Textbook Cornerstone #2: Fundamentals First Postpone Concepts That Require Complex Syntax We feel that many introductory programming textbooks jump too quickly into concepts that require com- plex syntax. In using complex syntax early, students get in the habit of entering code without fully under- standing it or, worse yet, copying and pasting from example code without fully understanding the example code. That can lead to less-than-ideal programs and students who are limited in their ability to solve a wide variety of problems. Thus, we prefer to postpone concepts that require complex syntax. We prefer to intro- duce such concepts later on, when students are better able to understand them fully. As a prime example of that philosophy, we cover the simpler forms of GUI programming early (in an optional graphics track), but we cover the more complicated forms of GUI programming later in the book. Specifically, we postpone event-driven GUI programming until the end of the book. This is dif- ferent from some other Java textbooks, which favor early full immersion into event-driven GUI pro- gramming. We feel that strategy is a mistake because proper event-driven GUI programming requires a great deal of programming maturity. When they learn it at the end of the book, our readers are better able to understand it fully. dea75768_fm_i-xxxviii.indd 13 4/30/20 11:54 AM
  • 9. xiv Preface Tracing Examples To write code effectively, it’s imperative to understand code thoroughly. We’ve found that step-by-step tracing of program code is an effective way to ensure thorough understanding. Thus, in the earlier parts of the textbook, when we introduce a new programming structure, we often illustrate it with a meticulous trace. The detailed tracing technique we use illustrates the thought process programmers employ while debugging. It’s a printed alternative to the sequence of screen displays generated by debuggers in inte- grated development environment (IDE) software. Input and Output In the optional GUI-track sections and in the GUI chapters at the end of the book, we use GUI commands for input and output (I/O). But because of our emphasis on fundamentals, we use console commands for I/O for the rest of the book.2 For console input, we use the Scanner class. For console output, we use the standard System.out.print, System.out.println, and System.out.printf methods. Textbook Cornerstone #3: Real World More often than not, today’s classroom students and industry practitioners prefer to learn with a hands- on, real-world approach. To meet this need, our textbook and its associated website include: ∙ compiler tools ∙ complete program examples ∙ practical guidance in program design ∙ coding-style guidelines based on industry standards ∙ Unified Modeling Language (UML) notation for class relationship diagrams ∙ practical homework-project assignments Compiler Tools We do not tie the textbook to any particular compiler tool—you are free to use any compiler tool(s) that you like. If you do not have a preferred compiler in mind, then you might want to try out one or more of these: ∙ Java Standard Edition Development Kit (JDK), by Oracle ∙ TextPad, by Helios ∙ Eclipse, by the Eclipse Foundation ∙ Netbeans, backed by Oracle ∙ BlueJ, by the University of Kent and Deaken University To obtain the above compilers, visit our textbook website at http://www.mhhe.com/dean3e, find the appropriate compiler link(s), and download away for free. Complete Program Examples In addition to providing code fragments to illustrate specific concepts, our textbook contains lots of com- plete program examples. With complete programs, students are able to (1) see how the analyzed code ties in with the rest of a program, and (2) test the code by running it. 2 We introduce GUI I/O at the end of Chapter 3 with dialog boxes. That opens up an optional door for GUI fans. If readers are so inclined, they can use the Alert, TextInputDialog, and ChoiceDialog classes to implement all our programs with GUI I/O rather than console I/O. dea75768_fm_i-xxxviii.indd 14 4/30/20 11:54 AM
  • 10. Preface xv Coding-Style Conventions We include coding-style tips throughout the textbook. The coding-style tips are based on Oracle’s coding conventions (https://www.oracle.com/technetwork/java/codeconvtoc-136057.html), Google’s coding con- ventions (https://google.github.io/styleguide/javaguide.html), and industry practice. In Appendix 5, we provide a complete reference for the book’s coding-style conventions and an associated example program that illustrates these conventions. UML Notation UML has become a standard for describing the entities in large software projects. Rather than overwhelm beginning programmers with syntax for the entire UML (which is quite extensive), we present a subset of UML. Throughout the textbook, we incorporate UML notation to represent classes and class relationships pictorially. For those interested in more details, we provide additional UML notation in Appendix 7. Homework Problems We provide homework problems that are illustrative, practical, and clearly worded. The problems range from easy to challenging. They are grouped into three categories—review questions, exercises, and proj- ects. We include review questions and exercises at the end of each chapter, and we provide projects on our textbook’s website. The review questions tend to have short answers, and the answers are in the textbook. The review questions use these formats: short-answer, multiple-choice, true/false, fill-in-the-blank, tracing, debugging, and write a code fragment. Each review question is based on a relatively small part of the chapter. The exercises tend to have short to moderate-length answers, and the answers are not in the textbook. The exercises use these formats: short-answer, tracing, debugging, and write a code fragment. Exercises are keyed to the highest prerequisite section number in the chapter, but they sometimes integrate concepts from several parts of the chapter. For this third edition, we have changed almost all of the end-of-chapter exercises, including exercises associated with unchanged material in the body of the text. The projects consist of problem descriptions whose solutions are complete programs. Project solu- tions are not in the textbook. Projects require students to employ creativity and problem-solving skills and apply what they’ve learned in the chapter. These projects often include optional parts, which provide chal- lenges for the more talented students. Projects are keyed to the highest prerequisite section number in the chapter, but they often integrate concepts from several preceding parts of the chapter. For this third edition, we have modified old projects and added new projects to make all projects conform to content in the body of the current text. Because the most substantial body-of-text changes are in the final three chapters, most of the project modifications and additions are associated with these chapters. An important special feature of this book is the way that it specifies problems. “Sample sessions” show the precise output generated for a particular set of input values. These sample sessions include inputs that represent typical situations and sometimes also extreme or boundary situations. Academic-Area Projects To enhance the appeal of projects and to show how the current chapter’s programming techniques might apply to different areas of interest, we take project content from several academic areas: ∙ computer science and numerical methods ∙ business and accounting dea75768_fm_i-xxxviii.indd 15 4/30/20 11:54 AM
  • 11. xvi Preface ∙ social sciences and statistics ∙ math and physics ∙ engineering and architecture ∙ biology and ecology Most of the academic-area projects do not require prerequisite knowledge in a particular area. Thus, instructors are free to assign almost any of the projects to any of their students. To provide a general reader with enough specialized knowledge to work a problem in a particular academic area, we sometimes expand the problem statement to explain a few special concepts in that academic area. Most of the academic-area projects do not require students to have completed projects from earlier chapters; that is, most projects do not build on previous projects. Thus, for the most part, instructors are free to assign projects without worrying about prerequisite projects. In some cases, a project repeats a previous chapter’s project with a different approach. The teacher may elect to take advantage of this rep- etition to dramatize the availability of alternatives, but this is not necessary. Project assignments can be tailored to fit readers’ needs. For example: ∙ For readers outside of academia— Readers can choose projects that match their interests. ∙ When a course has students from one academic area— Instructors can assign projects from the relevant academic area. ∙ When a course has students with diverse backgrounds— Instructors can ask students to choose projects from their own academic areas, or instructors can ignore the academic-area delineations and simply assign projects that are most appealing. To help you decide which projects to work on, we’ve included a “Project Summary” section after the preface. It lists all the projects by chapter and section, and for each project, it specifies: ∙ prerequisite chapter and section ∙ academic area ∙ estimated difficulty ∙ a title and brief description After using the “Project Summary” section to get an idea of which projects you might like to work on, see the textbook’s website for the full project descriptions. Organization In writing this book, we lead readers through three important programming methodologies: structured programming, OOP, and event-driven programming. For our structured programming coverage, we intro- duce basic concepts such as variables and operators, if statements, and loops. Then we show readers how to call prebuilt methods from Oracle’s Java API library. Many of these methods, like those in the Math class, are non-OOP methods that can be called directly. Others, like those in the String class, are OOP methods that must be called by a previously created object. After an “interlude” that gives readers a brief taste of what it’s like to write methods in a non-OOP environment, we move into OOP programming, and introduce basic OOP concepts such as classes, objects, instance variables, instance methods, and construc- tors. We also introduce static variables and static methods, which are useful in certain situations. However, we note that they should be used less often than instance variables and instance methods. Next, we move dea75768_fm_i-xxxviii.indd 16 4/30/20 11:54 AM
  • 12. Preface xvii on to more advanced OOP concepts—arrays, collections, interfaces, and inheritance. Chapters on excep- tion handling and files provide a transition into event-driven GUI programming. We describe and employ event-driven GUI programming in the final three chapters. The content and sequence we promote enable students to develop their skills from a solid foundation of programming fundamentals. To foster this fundamentals-first approach, our book starts with a mini- mum set of concepts and details. It then gradually broadens concepts and adds detail later. We avoid over- loading early chapters by deferring certain less-important details to later chapters. GUI Track Many programmers find Graphical User Interface (GUI) programming to be fun. As such, GUI program- ming can be a great motivational tool for keeping readers interested and engaged. That’s why we include graphics sections throughout the book, starting in Chapter 1. We call those sections our “GUI track.” Most of these end-of-chapter sections use GUI code that complements the current chapter’s previously pre- sented non-GUI material. For readers who do not have time for the GUI track, no problem. Any or all of the GUI track sections may be skipped because the rest of the book does not depend on any of the GUI- track material. Although the rest of the book does not depend on the GUI-track material, be aware that some of the GUI-track sections depend on some of the material in prior GUI-track sections: ∙ Chapter 3’s GUI section introduces dialog boxes for user input, and dialog boxes are used in later GUI sections for Chapters 10, 11, 15, and 16. ∙ Chapters 8, 10, and 16 have GUI sections that implement a common program, with iterative enhance- ments in each new GUI section. ∙ Chapters 12 and 13 have GUI sections that implement a common GridWorld program (for readers interested in the College Board’s AP Computer Science A curriculum). The GridWorld code uses AWT and Swing GUI software. Chapter 1 In Chapter 1, we first explain basic computer terms—what are the hardware components, what is source code, what is object code, and so on. We then narrow our focus and describe the programming language we’ll be using for the remainder of the book—Java. Finally, we give students a quick view of the classic bare-bones “Hello World” program. We explain how to create and run the program using minimalist­ software—Microsoft’s Notepad text editor and Oracle’s command-line JDK tools. Chapter 2 In Chapter 2, we present problem-solving techniques with an emphasis on algorithmic design. In imple- menting algorithm solutions, we use generic tools—flowcharts and pseudocode—with pseudocode given greater weight. As part of our algorithm-design explanation, we describe structured programming tech- niques. In order to give students an appreciation for semantic details, we show how to trace algorithms. Chapters 3–5 We present structured programming techniques using Java in Chapters 3–5. Chapter 3 describes sequential programming basics—variables, input/output, assignment statements, and simple method calls. Chapter 4 describes nonsequential program flow—if statements, switch constructs, and loops. In Chapter 5, we explain methods in more detail and show readers how to use prebuilt methods in the Java API library. dea75768_fm_i-xxxviii.indd 17 4/30/20 11:54 AM
  • 13. xviii Preface In all three chapters, we teach algorithm design by solving problems and writing programs with the newly introduced Java syntax. Interlude This “mini-chapter” contains two programs that show how to write multiple methods without using OOP. The Interlude presents a fork in the road between two study sequences. For the standard study sequence, read the chapters in the standard order (Chapters 1 through 19). For the “objects later” study sequence, after reading Chapter 5, read the supplemental chapters S6 and S9 online before returning to Chapter 6, where you’ll begin your study of OOP in earnest. Chapters 6–7 Chapter 6 introduces the basic elements of OOP in Java. This includes implementing classes and imple- menting methods and variables within those classes. We use UML class diagrams and object-oriented tracing techniques to illustrate these concepts. Chapter 7 provides additional OOP details. It explains how reference variables are assigned, tested for equality, and passed as arguments to a method. It explains overloaded methods and constructors. It also explains the use of static variables, static methods, and different types of named constants. Chapter 8 While the art of program design and the science of computerized problem-solving are developed through- out the textbook, in Chapter 8, we focus on these aspects in the context of OOP. This chapter begins with an organized treatment of programming style. It introduces javadoc, the Java application that automati- cally generates documentation for user-programmers. It describes ways to communicate with users who are not programmers. It describes organizational strategies like separation of concerns, modularization, encapsulation, and provision of general-purpose utilities. Coded examples show how to implement these strategies. It describes the major programming paradigms—top-down design, bottom-up design, using pre-written software for low-level modules, and prototyping. Chapters 9–10 Chapter 9 describes arrays, including arrays of primitives, arrays of objects, and multidimensional arrays. It illustrates array use with complete programs that sort, search, and construct histograms. Chapter 10 describes Java’s powerful array alternative, ArrayList. This provides a simple example of generic-­element specification. It also introduces the Java Collections Framework, which in turn, provides natural illustrations of Java interfaces. The prewritten classes in the Java Collections Framework provide a simple introduction of sets, maps, and queues. A relatively short but complete program shows how the pre-written Java implementa- tions of these data structures can be used to create and traverse a multiconnected random network. Chapter 11 Chapter 11 describes another way to process a collection of data—recursion. This chapter includes a ­ discussion of various recursive strategies. It introduces recursion with a real-life example and a familiar problem that one can solve easily with either looping or recursion. Then it moves gradually to problems that are harder to solve with looping and more easily solved with recursion. Although this chapter appears after the chapter on ArrayLists and the Java Collections Framework, it does not depend on these ­ concepts—it uses just ordinary arrays. dea75768_fm_i-xxxviii.indd 18 5/12/20 1:23 PM
  • 14. Preface xix Chapter 12 Early on, students need to be immersed in problem-solving activities. Covering too much syntax detail early can detract from that objective. Thus, we initially gloss over some less-important syntax details and come back to those details later in Chapter 12. This chapter provides more details on items such as these: ∙ byte and short primitive types ∙ Unicode character set ∙ type promotions ∙ postfix versus prefix modes for the increment and decrement operators ∙ conditional operator ∙ short-circuit evaluation ∙ enum data type ∙ forEach method ∙ lambda expressions ∙ method references ∙ streams The chapter ends with a friendly introduction to a relatively large public-domain program called Grid- World, which the College Board has used for many years as part of its AP Computer Science A course of study. This gives students a glimpse of how larger programs are organized. Chapters 13–14 Chapters 13 and 14 describe class relationships in depth with numerous examples. Chapter 13 describes aggregation, composition, and inheritance. Chapter 14 describes advanced inheritance-related details such as the Object class, polymorphism, abstract classes, and the finer points of interfaces. An optional section at the end of Chapter 13 describes an extension of the GridWorld environment introduced in Chapter 12 and provides additional exposure to Java’s legacy AWT and Swing graphics. Exercises in Chapters 13 and 14 relate material in these two chapters to corresponding GridWorld features. Chapters 15−16 Chapter 15 describes exception handling, and Chapter 16 describes files. We present exception handling before files because file-handling code requires the use of exception handling. For example, to open a file one must check for an exception. In addition to simple text I/O, our treatment of files includes buffering, random access, channeling, and memory mapping. Chapters 17−19 As in the end-of-chapter GUI sections, Chapters 17−19 present GUI concepts using the JavaFX platform. But the programming strategies differ. What follows are the strategies used in Chapters 17–19 (which are different from the strategies used in the end-of-chapter GUI sections). For user input, the programs use the components TextField, TextArea, Button, RadioButton, CheckBox, ComboBox, ScrollPane, and Menu. For layout, the programs use the containers FlowPane, VBox, HBox, GridPane, BorderPane, TilePane, and TextFlow. For formatting, the programs use JavaFX CSS properties. Depending on how much and what kind of GUI techniques you’re interested in, you can study one or more of the end-of-chapter GUI sections or skip all of them. That won’t affect your ability to grasp what’s in Chapters 17−19. If you’re short on time, you can omit all of the book’s GUI material without compro- mising your understanding of other material in the book. dea75768_fm_i-xxxviii.indd 19 5/10/20 8:50 PM
  • 15. xx Preface Chapters S17−S18 Chapters S17 and S18 (the S’s stand for supplemental) are posted online. They describe the older Java GUI platforms—AWT and Swing. The trend has been for new Java programs to use JavaFX, and not AWT and Swing. However, there’s quite a bit of AWT and Swing code currently in production, and that means there’s still a need for Java programmers to understand the older techniques so they can update and improve existing code. So if you find yourself in that position, Chapters S17 and S18 are a good starting point for learning what you need to know. Appendices Most of the appendices cover reference material, like the ASCII character set and the operator precedence table. For this third edition, we have updated Appendix 4 by including a detailed description of Java modules. Subject-Matter Dependencies and Sequence-Changing Opportunities We’ve positioned the textbook’s material in a natural order for someone who wants fundamentals and also wants an early introduction to OOP. We feel that our order is the most efficient and effective one for learning how to become a proficient OOP programmer. Nonetheless, we realize that different readers have different content- ordering preferences. To accommodate those different preferences, we’ve provided some built-in flexibility. Figure 0.1 illustrates that flexibility by showing chapter dependencies and, more importantly, chapter ­ nondependencies. For example, the arrow between Chapter 3 and Chapter 4 means that Chapter 3 must be read prior to Chapter 4. Because there are no arrows going out of Chapters 1, 11, and 16 that point to other complete chapters, you may skip those chapters without losing prerequisite material that later chapters need. We use rectangles with rounded corners to indicate chapter sections that you may want to read in advance. If you choose that option, you’ll want to return to the normal chapter sequence after completing the advanced sections. Here are some sequence-changing opportunities revealed by Figure 0.1: ∙ Readers can skip Chapter 1, “Introduction to Computers and Programming.” ∙ For an earlier introduction to OOP, readers can read the OOP overview section in Chapter 6 after reading Chapter 1. ∙ Readers can learn OOP syntax and semantics in Chapter 6 after finishing Java basics in Chapter 3. ∙ For additional looping practice, readers can learn about arrays in Chapter 9 after finishing loops in Chapter 4. ∙ Readers can skip Chapter 11, “Recursion,” and Chapter 16, “Files.” ∙ Readers who prefer a late objects approach can postpone reading Chapter 6, “Object-Oriented Pro- gramming,” by first reading Chapter S6, “Writing Methods in a Non-Object-Oriented Environment,” Sections 9.1–9.6 (which explain the basics of arrays), and Chapter S9, “Arrays in a Non-Object- Oriented Environment.” ∙ For GUI programming, readers who prefer the Swing platform should read Chapters S17 and S18. To support content-ordering flexibility, the book contains “hyperlinks.” A hyperlink is an optional jump forward from one place in the book to another place. The jumps are legal in terms of prerequisite knowledge, meaning that the jumped-over (skipped) material is unnecessary for an understanding of the later material. We supply hyperlinks for each of the nonsequential arrows in Figure 0.1. For example, we supply hyperlinks that go from Chapter 1 to Chapter 6 and from Chapter 3 to Chapter 12. For each hyperlink tail end (in the earlier chapter), we tell the reader where they may optionally jump to. For each hyperlink target end (in the later chapter), we provide an icon at the side of the target text that helps readers find the place where they are to begin reading. dea75768_fm_i-xxxviii.indd 20 5/12/20 1:24 PM
  • 16. Preface xxi Figure 0.1 Chapter dependencies Ch 5: Using Prebuilt Methods Ch 1: Introduction Ch 2: Algorithms and Design Ch 3: Java Basics Ch 4: Control Statements §6.2 OOP Overview §6.1−§6.8 OOP Basics §12.6−§12.12 Alternate Coding Mechanisms §9.1−§9.6 Arrays §12.1−§12.5 Type Details Interlude Ch 8: Software Engineering Ch 6: Object-Oriented Programming Ch 7: OOP−Additional Details §11.1−§11.5 Non- Array Recursion §9.1−§9.6 Array Basics Chapter S6: Writing Methods in a Non-Object- Oriented Environment Chapter S9: Arrays in a Non-Object-Oriented Environment Ch 9: Arrays Ch 10: ArrayList and Introduction to Java Collections Framework Ch 12: Type Details and Alternate Coding Mechanisms Ch 11: Recursion Ch 13: Aggregation, Composition and Inheritance Ch 16: Files Ch 14: Inheritance and Polymorphism Ch 15: Exception Handling Ch S17: Swing GUI Programming Basics Ch 17: GUI Programming Basics Ch 18: GUI Programming— Layout Panes Ch 19: GUI Programming— Additional GUI Components, Additional Event Handlers, Animation Ch S18: Swing GUI Component Layout, Additional GUI Components dea75768_fm_i-xxxviii.indd 21 4/30/20 11:54 AM
  • 17. Discovering Diverse Content Through Random Scribd Documents
  • 18. It must have been ten o’clock when, as Crellock once more made his round, he saw that Hallam was asleep, and that Mrs Hallam had taken up the candle still burning, and with Julia holding her hand, was looking round the room as if for a last good-night. Then together they went to the door, hand in hand; the door closed; the light shone at the staircase window, then in their bedroom, where he watched it burn for about a quarter of an hour before it was extinguished, and all was dark. “I shan’t feel satisfied till I have her safe,” he said, as he walked slowly back to his old look-out that commanded the road. The wind came in stronger gusts now, for a few minutes, and then seemed to die quite away, while the clouds that overspread the sky grew so dense that it was hard to distinguish the trees and bushes a dozen yards from where he stood. He finished his cigar, thinking out his plans the while, and at last coming to the conclusion that it was an unnecessary task this watching, he was about to make one more turn round the verandah, and then enter by the window and go to bed, when he fancied he heard a door close, as if blown by the wind that was once more sighing about the place. “Just woke up, I suppose,” he said, and he walked towards the study window and looked in. Hallam had not moved, but was sleeping heavily in his old position. Crellock listened again, but all was perfectly still. It could not have been fancy. Certainly he had heard a door bang
  • 19. softly, and the sound seemed to come from this direction. He stood thinking, and then went round and tried the front door. “Fast.” He walked round to the back door, following the verandah all the way, and found that door also fast. “I couldn’t have been mistaken,” he said, as he listened again. Once more the wind was sighing loudly about the place, but the noise was not repeated, and he walked on to the dining- room window; but as he laid his hand upon the glass door and thrust it open, a current of air rushed in, and there was the same sound: a door blew to with a slight bang. Crellock closed and fastened the glass door as he stepped out and ran quickly round to the drawing-room, where it was as he suspected: the glass door similar to that he had just left was open, and blew to and fro. “There’s something wrong,” he said excitedly, his suspicions being aroused; and, dashing in, he upset a chair in crossing the room, and it fell with a crash, but he hurried on into the hall, through to the study, and caught Hallam by the arm. “Wake up!” he said excitedly. “Hallam! Wake up, man.” He had to shake him heavily before the drink stupefaction passed off, and then Hallam stood trembling and haggard, trying to comprehend his companion’s words. “Wrong?” he said. “Wrong? What’s wrong?”
  • 20. “I don’t know yet. Look sharp! Run up to your wife’s room. Take the candle. Quick, man; are you asleep?” In his dazed state Hallam staggered, and his hand trembled so that he could hardly keep the light anything like steady. There was the knowledge, though faintly grasped, that something was terribly wrong. He gathered that from his companion’s excited manner, and, stumbling on into the hall, blundered noisily up the stairs while Crellock stood breathing hard and listening. “Here, Millicent! Julie!” he cried hoarsely; “what’s the matter?” Crellock heard the lock handle turn, and the door thrown open so violently that it struck against the wall, but there was no reply from the voices of frightened women. “Do you hear? Milly—Julie! Why don’t you answer?” came from above, and Crellock’s harsh breathing became like the panting of some wild beast. For a few moments there was absolute silence; then the sound of stumbling, heavy steps, and Hallam came out on to the landing. “Steve!” he cried excitedly, perfectly sober now, “what is it? What does it mean? They’ve gone!” “I knew it,” cried Crellock with a furious cry. “I might have seen it if I had not been a fool. Come down quick! They’ve not gone far.” Candle in hand, Hallam came staggering down the stairs with his eyes staring and his face blotched with patches of white.
  • 21. “They’ve gone,” he stammered hoarsely. “What for? Where have they gone?” “Out into the dark night,” cried Crellock furiously. “There is only one way that they could go, and we must have them before they reach the town.” “Town!” faltered Hallam; “town!” for in the horror of his waking and the conscience hauntings of the moment, he seemed to see two ghastly white faces looking up at him from the black waters of the harbour. “Yes, come along, follow me as quickly as you can,” roared Crellock; and going swiftly through the dining-room he crossed the verandah and dashed out into the thick darkness that seemed to rise up as a protecting wall on behalf of those whom he pursued.
  • 22. Volume Four—Chapter Sixteen. The Flight. “I am so weak, my child,” sighed Mrs Hallam, “that my heart fails me. What shall I do?” Julia stood over her dressed for flight, and a chill of despair seized her. “Oh, mother, try—try,” she whispered. “I am trying, Julie. I am fighting so hard, but you cannot realise the step I am trying to take; you cannot see it, my child, as it is spread before me.” “Let us stay then,” whispered Julie, “and to-morrow I will appeal to Sir Gordon to come to our help.” “No,” said Mrs Hallam, firmly, as if the words of her child had given her strength, “we can ask help of no one in such a strait as this, Julie; the act must be mine and mine alone; but now the time has come, my child, I feel that it is too much.” “Mother!” sobbed Julie, “that man horrifies me. You heard all that my father said. I would sooner die than become his wife.” Mrs Hallam caught her arm with a sharp grip, and remained silent for a few moments. “Yes,” she said at last, “and much as I love you, my own, I would sooner see you dead than married to such a man as he. You have given me the courage I failed in, my darling. For myself, I would live and
  • 23. bear until the end; but I am driven to it—I am driven to it. Come.” They were standing in the dark, and now for the time being Mrs Hallam seemed transformed. Gathering her cloak about her, she went quickly to the door and listened, and then turned and whispered to Julia. “Come at once,” she said. “Follow me down.” Julia drew a long breath and followed her, trembling, the boards of the lightly-built house cracking loudly as she passed quickly to the stairs. And again in the silence and darkness these cracked as they passed down. In the hall Mrs Hallam hesitated for a moment, and then, putting her lips to Julia’s ear: “Stop!” she whispered. Julia stood listening, and with her eyes strained towards where a light shone beneath the ill-fitting study-door from which, in the stillness, the heavy stertorous breathing of Hallam could be heard. She could hear, too, the faint rustle of Mrs Hallam’s dress as she paced along the hall; and as Julia gazed in the direction she had taken, the light that streamed from beneath, and some faint rays from the side, showed indistinctly a misty figure which sank down on its knees and remained for a few moments. The silence was awful to the trembling girl, who could not repress a faint cry as she heard a loud cough coming from beyond the dining-room. But she, too, drew her breath hard, and set her teeth as if the nearness of her enemy provoked her to desperate resistance, and she stood waiting there firmly, but wondering the while whether they would be able to escape
  • 24. or be stopped in the act of flight by Crellock, whom she knew to be watching there. She dare not call, though she felt that her mother was again overcome by the terrors of the step they had resolved to take, and the moments seemed interminable before there was a change in the light beneath the door, and a faint rustle mingled with the heavy breathing. Then her hand was clasped by one like ice in its coldness, and, as if repeating the prayer she had been uttering, Julia heard her mother say in a faint whisper: “It is for her sake—for hers alone.” Julia drew her into the drawing-room as they had planned, and closed the door. Then Mrs Hallam seemed to breathe more freely. “The weakness has passed,” she said softly. “We must lose no time.” They crossed the room carefully to where a dim light showed the French window to be, and Mrs Hallam laid her hand upon it firmly, and turned the fastening after slipping the bolt. “Keep a good heart, my darling,” she said. “You are not afraid?” “Not of our journey, mother,” said Julia in agitated tones; “but of—a listener.” “Hist!” whispered Mrs Hallam, drawing back; and the window which she had opened swung to with a faint click, as the firm pace of Crellock was heard coming along the verandah; and as they stood there in the darkness they could see the dim figure pass the window.
  • 25. Had he stretched forth a hand, he would have felt the glass door yield, and have entered and found them there; and, knowing this, they stood listening to the beating of their hearts till the figure passed on and they heard the step of the self-constituted sentry grow faint on the other side of the house. “Julie, are you ready?” “Yes, mother; let us go—anywhere, so that I may not see that man again.” Mrs Hallam uttered a sigh of relief, for her child’s words had supplied her once more with the power that was failing. “It is for her sake,” she muttered again. Then, in a low whisper: “Quick! your hand. Come.” And they stepped out into the verandah, drew the door to without daring to stop to catch it, and the next minute they were threading their way amongst the trees of the garden, and making for the gate. The darkness was now intense, and though the faint twinkling of lights showed them the direction of the town, they had not gone far before they found themselves astray from the path, and after wandering here and there for a few minutes, Mrs Hallam paused in dread, for she found that there was now another enemy in her way upon which she had not counted. She spoke very calmly, though, as Julia uttered a gasp. “The wind is rising,” she said, “and it will soon grow lighter. Let us keep on.” They walked on slowly and cautiously in and out among the trees of what was, in the darkness, a complete wilderness.
  • 26. At times they were struggling through bushes that impeded their progress, and though time after time the track seemed to be found, they were deceived. It was as if Nature were fighting against them to keep them within reach of Hallam and his friend, and, though they toiled on, a second hour had elapsed and found them still astray. But now, as they climbed a steep slope, the wind came with a gust, the clouds were chased before it, there was the glint of a star or two, and Mrs Hallam uttered an exclamation. “There!” she cried, “to the left. I can see the lights now.” Catching Julia’s hand more firmly, she hurried on, for the night was now comparatively light, but neither uttered a word of their thoughts as they gave a frightened glance back at a dim object on the hill behind, for they awoke to the fact that they had been wandering round and about the hill and gully, returning on their steps, and were not five hundred yards away from their starting-point. At the end of a quarter of an hour the stars were out over half the vault of heaven, and to their great joy the path was found—the rough track leading over the unoccupied land to the town. “Courage! my child,” whispered Mrs Hallam; “another hour or two and we shall be there.” “I am trying to be brave, dear,” whispered back Julia as the track descended into another gully; “but this feeling of dread seems to chill me, and—oh! listen!” Mrs Hallam stopped, and plainly enough behind them there was the sound of bushes rustling; but the sound ceased directly.
  • 27. “Some animal—that is all,” said Mrs Hallam, and they passed on. Once more they heard the sound, and then, as they were ascending a little eminence before descending another of the undulations of the land, there came the quick beat of feet, and mother and daughter had joined in a convulsive grasp. “We are followed,” panted Mrs Hallam. “We must hide.” As she spoke they were on the summit of the slope, with their figures against the sky-line to any one below, and in proof of this there was a shout from a short distance below, and a cry of “Stop!” “Crellock!” muttered Mrs Hallam, and she glanced from side to side for a place of concealment, but only to see that the attempt to hide would be only folly. “Can you run, Julie?” she whispered. For answer Julia started off, and for about a hundred yards they ran down the slope, and then stopped, panting. They could make no further effort save that of facing their pursuer, who dashed down to them breathless. “A pretty foolish trick,” he cried. “Mercy I found you gone, and came. What did you expect would become of you out here in the night?” “Loose my hand,” cried Julia angrily; “I will not come back.” “Indeed, but you will, little wifie. There, it’s of no use to struggle; you are mine, and must.” “Julia, hold by me,” cried Mrs Hallam frantically. “Help!”
  • 28. “Hah!” That ejaculation was from Crellock, for as Mrs Hallam’s appeal for help rang out amongst the trees of the gully into which they had descended, there was the dull sound of a heavy blow, and their assailant fell with a crash amongst the low growth of scrub. “This way,” said a familiar voice. “Do you want to join Thisbe King?” “Yes, yes,” cried Julia, sobbing now; “but how did you know?” “How did I know!” was the reply, half sadly, half laughingly. “Oh, I have played the spy: waiting till you wanted help.” “Christie Bayle!” wailed Mrs Hallam; “my friend in need.” He did not answer. He hardly heard her words as Mrs Hallam staggered on by his side, for two little hands were clinging to his arm, Julia’s head was resting against him, as she nestled closer and closer, and his heart beat madly, for it seemed to him as if it was in his breast that Julia Hallam would seek for safety in her time of need.
  • 29. Volume Four—Chapter Seventeen. In Sanctuary. “Let them come if they dare, my dear,” said Thisbe stoutly. “I’ve only waited for this. You know how I’ve never said word against him, but have seen and borne everything.” “Yes, yes,” sighed Mrs Hallam. “For, I said to myself, the day will come when she will see everything in its true light, and then—” Thisbe said no more, but cut her sentence in half by closing her lips more tightly than they had ever been closed before, as, with a smile, she busied herself about Julia and her mother. “I was in a way last night,” she said cheerily, as she straightened first one thing and then another in the modest lodgings she had secured, “but I daren’t come away for fear you might get here while I was looking for you. You don’t know the relief I felt when Mr Bayle knocked at the door with you two poor tired things. There, you needn’t say a word, only be quiet and rest.” Thisbe nodded from one to the other, and smiled as if there was not a trouble in the world. Then she stood rolling up her apron, and moistening her lips, as if there was something she wanted to say but hesitated. At last she went to Mrs Hallam’s side, and took hold of the sleeve of her dress. “Let me go and ask Mr Bayle to take berths for you on board the first ship that’s going to sail, and get taken away
  • 30. from this dreadful place.” Mrs Hallam gazed at her wistfully, but did not answer for a few moments. “I must think, Thibs,” she said. “I must think; and now I cannot, for I feel as if I am stunned.” “Then lie down a bit, my dear Miss Milly. Do, dear. She ought to, oughtn’t she, Miss Julie? There, I knew she would. It’s to make her strong.” It was as if old girlish days had come back, for Mrs Hallam yielded with a sigh to the stronger will of the faithful old servant, letting her lift and lay her down, and closing her eyes with a weary sigh. “Now I may go to Mr Bayle, mayn’t I?” “No,” said Mrs Hallam sternly. “Then to Sir Gordon, and ask him to help us?” “No,” said Mrs Hallam again; “I must work alone in this— and I will.” She closed her eyes, and in a few minutes seemed to have dropped off asleep, when Thisbe signed to Julia to accompany her out of the room. “Don’t you fret and trouble yourself, my darling,” she whispered. “I’ll take care no one comes and troubles you. She’s worn out with suffering, and no doctor would do her good, or we’d soon have the best in the town. What she wants is rest and peace, and your dear loving hands to hold her. If anything will ease her that’s it.”
  • 31. She kissed Julia, and the next moment the girl’s arms were clasped about her neck, and she sobbed upon her breast. “It’s so terrible,” she cried. “I can’t bear it! I can’t bear it! I tried so hard to love him, but—but—” “An angel with wings couldn’t have loved such a father as that, my dear.” “Thibs!” “Well, there, then, I won’t say much, my darling; but don’t you fret. You’ve both done quite right, for there’s a pynte beyond which no one can go.” “But if we could win him back to—” “Make you marry that man Crellock! Oh, my darling, there’s no winning him back. I said nothing and stood by you both to let you try, and I was ready to forgive everything; but oh, my pet! I knew how bad it all was from the very first.” “No, no, Thibs, you didn’t think him guilty when he was sent out here.” “Think, my dear! No: I knew it, and so did Sir Gordon and Mr Bayle, but for her sake they let her go on believing in him. Oh! my dear, only that there’s you here, I want to know why such a man was ever allowed to live.” “Thibs, he is my father,” cried Julia angrily. “Yes, my dear, and there’s no changing it, much as I’ve thought about it.” Julia stood thinking.
  • 32. “I shall go to him,” she said at last, “with you, and tell him why we have left him. I feel, Thibs, as if I must ask him to forgive me, for I am his child.” “You wait a bit, my dear, and then talk about forgiveness by-and-by. You’ve got to stay with your poor mother now. Why, if you left her on such an errand as that, what would happen if he kept you, and wouldn’t let you come back?” Julia’s eyes dilated, and her careworn face grew paler. “He would not do that.” “He and that Crellock would do anything, I believe. There, you can’t do that now. You’ve got to sit and watch by her.” “Julia!” came in an excited voice from the next room. “There, what did I tell you, my dear?” said Thisbe; and she hurried Julia back and closed the door. “They’ll go back and forgive him if he only comes and begs them to, and he’ll finish breaking her heart,” said Thisbe, as she went down. “Oh, there never was anything so dreadful as a woman’s weakness when once she has loved a man. But go back they shall not if I can help it, and what to do for the best I don’t know.” She went into the little sitting-room, seated herself, and began rolling her apron up tightly, as she rocked herself to and fro, and all the time kept on biting her lips. “I daren’t,” she said. “She would never forgive me if she knew. No, I couldn’t.” She went on rocking herself to and fro.
  • 33. “I will—I will do it. It’s right, for it’s to save them; it’s to save her life, poor dear, and my darling from misery.” She started from her chair, wringing her hands, and with her face convulsed, ending by falling on her knees with clasped hands. “Oh, please God, no,” she cried, “don’t—don’t suffer that— that darling child to be dragged down to such a fate. I couldn’t bear it. I’d sooner die! For ever and ever. Amen.” She sobbed as she crouched lower and lower, suffering an agony of spirit greater than had ever before fallen to her lot, and then rose, calm and composed, to wipe her eyes. “I’ll do it, and if it’s wicked may I be forgiven. I can’t bear it, and there’s only that before he puts the last straw on.” There was a loud tap at the door just then, evidently given by a hard set of knuckles. “It’s them!” cried Thisbe excitedly; “it’s them!” The door was locked and bolted, and she glanced round the room as if in search of a weapon. Then going to the window, she looked sidewise through the panes, and her hard, angry face softened a little, and she opened the window. “How did you know I was wanting you to come?” Tom Porter’s hard brown face lit up with delight. “Was you?” he cried; “was you, Thisbe? Lor’! how nice it looks to see you in a little house like this, and me coming to the door; but you might let me in. Are you all alone?” “Don’t you get running your thick head up against a wall, Tom Porter, or you’ll hurt it. And now, look here, don’t you
  • 34. get smirking at me again in that way, or off you go about your business, and I’ll never look at you again.” “But Thisbe, my dear, I only—” “Don’t only, then,” she said, in a fierce whisper; “and don’t growl like that, or you’ll frighten them as is upstairs into thinking it’s some one else.” “All right, my lass; all right. Only you are very hard on a man. You was hard at King’s Castor, you was harder up at Clerkenwell, while now we’re out here rocks is padded bulkheads to you.” “I can’t help it, Tom; I’m in trouble,” said Thisbe more gently. “Are you, my lass? Well, let me pilot you out.” “Yes, I think you shall,” she said, “I wanted you to come.” “Now, that’s pleasant,” said Tom Porter, smiling; “and it does me good, for the way in which I wants to help you, Thisbe, is a wonder even to me.” “Oh, yes, I know,” she said grimly. “Now then, why did you come?” “You said you wanted me.” “Yes; but tell me first why you came.” “The Admiral sent me to say that he was waiting for the missus’s commands, and might he come down and see her on very partic’lar business? He couldn’t write, his hand’s all a shake, and he ain’t been asleep all night.”
  • 35. “Tell him, and tell Mr Bayle, too, that my mistress begs that she may be left alone for the present. She says she will send to them if she wants their help.” “Right it is,” said Tom Porter. “Now then, what did you want along o’ me?” Thisbe’s face hardened and then grew convulsed, and the tears sprang to her eyes. Then it seemed to harden up again, and she took hold of Tom Porter’s collar and whispered to him quickly. “Phe-ew!” whistled Sir Gordon’s man. She went on whispering in an excited way. “Yes, I understand,” he said. She whispered to him again more earnestly than ever. “Yes. Not tell a soul—and only if—” “Yes.” “Only if—” “Yes, yes,” whispered Thisbe. “Mind, I depend upon you.” “If Tom Porter’s a living soul,” he replied, “it’s done. But you do mean it?” “I mean it,” said Thisbe King. “Now go.” “One moment, my lass,” he said. “I’ve been very humble, and humble I am; but when this trouble’s over and smooth water comes, will you?”
  • 36. Thisbe did not answer for a few moments, and then it was in a softened voice. “Tom Porter,” she said, “there’s one upstairs half dead with misery, and her darling child suffering more than words can tell. My poor heart’s full of them; don’t ask me now.” Tom Porter gave his lips a smart slap and hurried down the street, while Thisbe closed the window and went back to her chair, to rock herself to and fro again, with her hands busily rolling and unrolling her apron. “I’ve done it,” she said; “but it all rests on him. It’s his own doing.” Then, after a pause: “How long will it be before they find out where we are? Not long. Hah!” Thisbe King passed her hands up and down her bare brawny arms, and her face tightened for the encounter which she felt must come before long.
  • 37. Volume Four—Chapter Eighteen. The Blow Falls. It was close upon evening before the trouble Thisbe expected came. Tom Porter had been again, tapped at the door, and when Thisbe went to the window he had contorted his face in the most horrible manner, closing his left eye, and then walked off without a word. Thisbe watched till he was out of sight, and then returned to her chair. “He’s to be trusted,” she said to herself. “It’s a pity he wants to marry me. We’re much better as we are; and who knows but what he might turn wild? There’s only one thing in his favour, he ain’t a handsome man.” Now Tom Porter at fifty looked to be about the last person in the world to turn wild, but Thisbe’s experiences had done much to harden her virgin heart. At least a dozen times over she had slipped off her shoes and ascended the stairs to find that, utterly exhausted, Mrs Hallam and Julia were sleeping heavily, the latter on a chair, with her arms clasped about her mother’s neck. “Poor dears!” said Thisbe, as she descended; “I daren’t wake them, but they ought to have a cup of tea.” “Ah,” she exclaimed softly, “what would she say? I shall never dare to look her in the face again.” At last the trouble came.
  • 38. “I knew it,” said Thisbe, as she heard the steps at the door. “He was bound to find us. Yes, they’re both there. Well, it’s his own work and not mine. What shall I do?” She rose from her chair, looking very resolute. “I’ll face them bold. It’s the only way.” She heard the murmur of men’s voices, and then there was a rap at the door given with the handle of a whip. She went to the door, unfastened and threw it open. “What is it?” she said. Hallam and Crellock were on the threshold, and the latter exclaimed, as soon as he saw her: “I thought so.” They stepped in quickly, and Thisbe’s lips tightened as she was forced to back before them, and the door swung to. “Where is your mistress?” said Hallam sharply. “Asleep. Worn out and ill.” “Where’s my daughter?” “With her mother: upstairs.” “I’ll soon have an end of this fooling,” he exclaimed; and as Thisbe stood with her arms folded, she seemed to see a flash of the old look she remembered—the look she hated— when they were at Castor years before. Hallam threw open the door at the foot of the narrow staircase, while Crellock seated himself astride a chair with his hat on and beat his boot with his whip.
  • 39. “Millicent! Julie!” cried Hallam fiercely, and there were footsteps heard above, for the arrival had awakened those who slept. “Come down at once.” He let the door swing to and began to pace the little room, muttering to himself, and evidently furious with rage at his wife’s desertion. Crellock watched him from the corner of his eyes, and from time to time unconsciously applied his hand to a great discolouration on the cheek. He was evidently quite satisfied, for Hallam needed no egging on to the task, and he felt that this episode would hasten his marriage. “Are you coming?” cried Hallam, after a few minutes, and as he flung back the door, that of the bedroom was heard to open, and Mrs Hallam and Julia came down, both very pale, but with a firmness in their countenances that sent a thrill of joy through Thisbe. “There you are then,” cried Hallam, as they stood before him. “Ah! I’ve a good mind to—” He raised his hand and made a feint as if to strike the pale, suffering woman. With a cry of horror, Julia flung herself between them, her eyes flashing, her dread gone, and in its place, indignant horror sweeping away the last feeling of pity and compunction for the brutalised man to whom she owed her birth. “Now then,” cried Hallam. “You’ve both had your fool’s game out, so put on your bonnets and come home.” Mrs Hallam passed her hand round Julia and remained silent. “Do you hear?” cried Hallam. “I say, put on your things and come home. As for you, madam, you shall have a home of your own, and a husband, before you know where you are.
  • 40. Come; stir!” he cried, with a stamp. “This is my home,” said Mrs Hallam, sternly. “What!” “Robert Hallam, the last thread that bound me to you is broken,” she continued, in a calm, judicial voice. “We are separated for ever.” “You’re mad,” cried Hallam, with a laugh. “Come, no nonsense, ma’am! Don’t make a scene, for I’m not in the humour to put up with much. Come out of this house or—” He made a step or two towards the door, for Thisbe had thrown it open, having seen Bayle pass the window with Sir Gordon. Then he seized the door to fling it in their faces; but Thisbe held it firmly, and they walked in, Hallam himself giving way. “Coward!” snarled Crellock in his ear, as he started up, whip in hand. “Mrs Hallam,” said Sir Gordon, “you must forgive this intrusion. I am sure we are wanted here.” “Wanted here!” cried Hallam savagely; “no, you are not wanted here. I’ll have no more interferences from such as you; you’ve both been the curse of my life.” Sir Gordon turned upon him with a calm look of disgust and contempt, which at another time would have made him quail; but, fevered with brandy as he was, the effect was to make him more beside himself. “As you are here, both of you, let me tell you this: that I don’t kick you out because one of you is a weak, doddering old idiot, the other—oh, his cloth must protect Mr Bayle. Now what do you want?”
  • 41. “Be calm, Julia,” whispered Bayle. “No harm shall befall either of you.” Crellock advanced menacingly, but Sir Gordon interposed. “Mrs Hallam, as your father’s old friend, I must interfere for your protection now.” “Must you?” cried Hallam fiercely, “then I tell you that you won’t. This is my house, taken by my wife. That is my wife. That is my child, and in a few days she will be the wife of this gentleman, my oldest friend. Now go. Millicent—Julie— get on your things, and come, or, by all that’s holy, we’ll drag you through the streets.” Julia clung to Bayle, and turned her flushed face to him as if asking help; while, with a look of calm contempt, he patted the hand he held, and glanced at Mrs Hallam, for something seemed to warn him that the crisis had arrived. “I have told you, Robert Hallam,” she said, in a calm, firm voice, that grew in strength as she went on, “that from this hour we are separated, never to be man and wife again. I clung to you in all a woman’s proud faith in her husband. I loved you as dearly as woman could love. When you were condemned of all, I defended you, and believed you honest.” “Bah!” he exclaimed; “enough of this!” and he took a step forward, but quailed before her gaze. “You crushed my love. You made me your wretched innocent tool and slave when you brought me here, and at last you brutally told me all the cruel truth. Even then, heartbroken, I clung to you, and suffered in silence. God knows how I tried to bring you to penitence and a better
  • 42. life. I forgave all for the sake of our child; and in my love for her I would have gone on bearing all.” “Have you nearly done?” he said mockingly. “Nearly,” she said, in the same firm, clear tones; and she seemed to tower above him, pale and noble of aspect, while he, drink-brutalised and blotched, seemed to shrink. “I say I would have borne everything, even if you had beaten me like a dog. But when—oh, my God, judge between us and forgive me if I have done wrong!—when I am called upon to see my innocent child dragged down by you to the fate of being the wife of the villain who has been your partner in all your crimes, my soul revolts, and I say— from this hour all between us is at an end.” “And I say,” he yelled, “that you are my wife, this my child, and you shall obey me. Come; I am master here.” He made a snatch at her arm, but she raised it before him, with outstretched palm, and her voice rang out with a cry that made him shrink and cower. “Stop!” There was a moment’s utter silence, broken by the softly heard tramp of feet. “Husband no longer, father of my child no more. Robert Hallam, you are my convict servant! I discharge you. Leave this house!” Hallam took a step back, literally stunned by the words of the outraged woman, who for so long a time had been his slave, while Bayle uttered a long sighing sound as if relieved of some terrible weight.
  • 43. For a time no one spoke, but all turned from gazing on the prominent figure of that group, to Hallam, who stood clenching and unclenching his hands, and gasping as if trying to recover from the shock he had received. He essayed to speak as he glared at Mrs Hallam, and scowled at her as if each look were an arrow to wound and bring her to his feet humbled and appealing as of old; but the arrows glanced from the armour of indignant maternal love with which she was clothed; and, drawn up to her full height, scornful and defiant as she seemed, her look absolutely made him quail. Tramp—tramp—tramp—tramp. The regular march of disciplined men coming nearer and nearer, but heard by none within that room, as Crellock, with a coarse laugh, bent forward, and whispered in his companion’s ear: “Why, man, are you going to submit to this?” “No!” roared Hallam, as if his gang-companion’s words had broken a spell. “No! The woman’s mad! Julia, you are my child. Come here!” Julia met the eyes that were fixed fiercely upon her, and stepped forward. Bayle tried to arrest her, but she raised her hand to keep him back, and then placed it on her father’s arm, trembling and looking white. Then she reached up, and kissed him solemnly upon the cheek. “There, gentlemen,” he cried triumphantly. “You see. Now, wife—my wife, come to your convict servant—come—home.”
  • 44. Welcome to our website – the ideal destination for book lovers and knowledge seekers. With a mission to inspire endlessly, we offer a vast collection of books, ranging from classic literary works to specialized publications, self-development books, and children's literature. Each book is a new journey of discovery, expanding knowledge and enriching the soul of the reade Our website is not just a platform for buying books, but a bridge connecting readers to the timeless values of culture and wisdom. With an elegant, user-friendly interface and an intelligent search system, we are committed to providing a quick and convenient shopping experience. Additionally, our special promotions and home delivery services ensure that you save time and fully enjoy the joy of reading. Let us accompany you on the journey of exploring knowledge and personal growth! ebookluna.com