100% found this document useful (4 votes)
8 views

(eBook PDF) Starting Out with Java: From Control Structures through Data Structures 3rd Edition download

The document provides links to various eBooks related to Java and C++ programming, including multiple editions of 'Starting Out with Java' and 'Data Structures and Abstractions with Java'. It offers instant digital downloads in formats like PDF, ePub, and MOBI. Additionally, it includes a table of contents for the Java programming book, detailing topics covered such as control structures, loops, and file input/output.

Uploaded by

stephwadas2s
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
8 views

(eBook PDF) Starting Out with Java: From Control Structures through Data Structures 3rd Edition download

The document provides links to various eBooks related to Java and C++ programming, including multiple editions of 'Starting Out with Java' and 'Data Structures and Abstractions with Java'. It offers instant digital downloads in formats like PDF, ePub, and MOBI. Additionally, it includes a table of contents for the Java programming book, detailing topics covered such as control structures, loops, and file input/output.

Uploaded by

stephwadas2s
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

(eBook PDF) Starting Out with Java: From Control

Structures through Data Structures 3rd Edition


install download

https://ebookluna.com/product/ebook-pdf-starting-out-with-java-
from-control-structures-through-data-structures-3rd-edition/

Download more ebook from https://ebookluna.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

(eBook PDF) Starting Out with Java: From Control


Structures through Data Structures 4th Edition

https://ebookluna.com/product/ebook-pdf-starting-out-with-java-from-
control-structures-through-data-structures-4th-edition/

ebookluna.com

(eBook PDF) Starting Out with Java: From Control


Structures through Objects, 7th Edition

https://ebookluna.com/product/ebook-pdf-starting-out-with-java-from-
control-structures-through-objects-7th-edition/

ebookluna.com

(eBook PDF) Starting Out with C++: From Control Structures


through Objects 8th Edition

https://ebookluna.com/product/ebook-pdf-starting-out-with-c-from-
control-structures-through-objects-8th-edition/

ebookluna.com

(eBook PDF) Starting Out with C++: From Control Structures


through Objects, Brief Version 8th Edition

https://ebookluna.com/product/ebook-pdf-starting-out-with-c-from-
control-structures-through-objects-brief-version-8th-edition/

ebookluna.com
(eBook PDF) Starting Out with C++ from Control Structures
to Objects 9th Edition

https://ebookluna.com/product/ebook-pdf-starting-out-with-c-from-
control-structures-to-objects-9th-edition/

ebookluna.com

(eBook PDF) Data Structures and Abstractions with Java 4th


Edition

https://ebookluna.com/product/ebook-pdf-data-structures-and-
abstractions-with-java-4th-edition/

ebookluna.com

Data Structures and Abstractions with Java 5th Edition


(eBook PDF)

https://ebookluna.com/product/data-structures-and-abstractions-with-
java-5th-edition-ebook-pdf/

ebookluna.com

(eBook PDF) Data Structures and Abstractions with Java 4th


Global Edition

https://ebookluna.com/product/ebook-pdf-data-structures-and-
abstractions-with-java-4th-global-edition/

ebookluna.com

(eBook PDF) Starting Out with Java: Early Objects 5th


Edition

https://ebookluna.com/product/ebook-pdf-starting-out-with-java-early-
objects-5th-edition/

ebookluna.com
Contents vii

Having Multiple Conditionally Executed Statements . . . . . . . . . . . . . . . . 119


Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Comparing Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
3.2 The if-else Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
3.3 Nested if Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
3.4 The if-else-if Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
3.5 Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
The Precedence of Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Checking Numeric Ranges with Logical Operators . . . . . . . . . . . . . . . . . 144
3.6 Comparing String Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Ignoring Case in String Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
3.7 More about Variable Declaration and Scope . . . . . . . . . . . . . . . . . . . 151
3.8 The Conditional Operator (Optional) . . . . . . . . . . . . . . . . . . . . . . . . 152
3.9 The switch Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
3.10 Displaying Formatted Output with System.out.printf
and String.format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Format Specifier Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Precision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Specifying a Minimum Field Width . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Formatting String Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
The String.format Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
3.11 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Review Questions and Exercises   179
Programming Challenges   184

Chapter 4 Loops and Files   189


4.1 The Increment and Decrement Operators . . . . . . . . . . . . . . . . . . . . . 189
The Difference between Postfix and Prefix Modes . . . . . . . . . . . . . . . . . . 192
4.2 The while Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
The while Loop Is a Pretest Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Infinite Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Don’t Forget the Braces with a Block of Statements . . . . . . . . . . . . . . . . 197
Programming Style and the while Loop . . . . . . . . . . . . . . . . . . . . . . . . 198
4.3 Using the while Loop for Input Validation . . . . . . . . . . . . . . . . . . . . 200
4.4 The do-while Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
4.5 The for Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
The for Loop Is a Pretest Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Avoid Modifying the Control Variable in the Body
of the for Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Other Forms of the Update Expression . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Declaring a Variable in the for Loop’s Initialization Expression . . . . . . . 211
Creating a User Controlled for Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
Using Multiple Statements in the Initialization
and Update Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
viii Contents

4.6 Running Totals and Sentinel Values . . . . . . . . . . . . . . . . . . . . . . . . . . 216


Using a Sentinel Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
4.7 Nested Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
4.8 The break and continue Statements (Optional) . . . . . . . . . . . . . . . . 229
4.9 Deciding Which Loop to Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
4.10 Introduction to File Input and Output . . . . . . . . . . . . . . . . . . . . . . . . 230
Using the PrintWriter Class to Write Data to a File . . . . . . . . . . . . . . . 230
Appending Data to a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Specifying the File Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
Reading Data from a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
Reading Lines from a File with the nextLine Method . . . . . . . . . . . . . . . 238
Adding a throws Clause to the Method Header . . . . . . . . . . . . . . . . . . . 241
Checking for a File’s Existence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
4.11 Generating Random Numbers with the Random Class . . . . . . . . . . . . 249
4.12 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Review Questions and Exercises   256
Programming Challenges   262

Chapter 5 Methods   269


5.1 Introduction to Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
void Methods and Value-Returning Methods . . . . . . . . . . . . . . . . . . . . 270
Defining a void Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Calling a Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Hierarchical Method Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
Using Documentation Comments with Methods . . . . . . . . . . . . . . . . . . 278
5.2 Passing Arguments to a Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
Argument and Parameter Data Type Compatibility . . . . . . . . . . . . . . . . 281
Parameter Variable Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
Passing Multiple Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
Arguments Are Passed by Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
Passing Object References to a Method . . . . . . . . . . . . . . . . . . . . . . . . . 285
Using the @param Tag in Documentation Comments . . . . . . . . . . . . . . . 288
5.3 More about Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Local Variable Lifetime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
Initializing Local Variables with Parameter Values . . . . . . . . . . . . . . . . . 292
5.4 Returning a Value from a Method . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Defining a Value-Returning Method . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Calling a Value-Returning Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
Using the @return Tag in Documentation Comments . . . . . . . . . . . . . . 296
Returning a boolean Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
Returning a Reference to an Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
5.5 Problem Solving with Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
Calling Methods That Throw Exceptions . . . . . . . . . . . . . . . . . . . . . . . . 306
5.6 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
Review Questions and Exercises   307
Programming Challenges   312
Contents ix

Chapter 6 A First Look at Classes   319


6.1 Objects and Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
Classes: Where Objects Come From . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
Classes in the Java API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
Primitive Variables vs. Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
6.2 Writing a Simple Class, Step by Step . . . . . . . . . . . . . . . . . . . . . . . . . 326
Accessor and Mutator Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
The Importance of Data Hiding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
Avoiding Stale Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
Showing Access Specification in UML Diagrams . . . . . . . . . . . . . . . . . . . 341
Data Type and Parameter Notation in UML Diagrams . . . . . . . . . . . . . .341
Layout of Class Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
6.3 Instance Fields and Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
6.4 Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
Showing Constructors in a UML Diagram . . . . . . . . . . . . . . . . . . . . . . . 350
Uninitialized Local Reference Variables . . . . . . . . . . . . . . . . . . . . . . . . . 350
The Default Constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
Writing Your Own No-Arg Constructor . . . . . . . . . . . . . . . . . . . . . . . . . 351
The String Class Constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
6.5 Passing Objects as Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
6.6 Overloading Methods and Constructors . . . . . . . . . . . . . . . . . . . . . . 372
The BankAccount Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
Overloaded Methods Make Classes More Useful . . . . . . . . . . . . . . . . . . 380
6.7 Scope of Instance Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
Shadowing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
6.8 Packages and import Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
Explicit and Wildcard import Statements . . . . . . . . . . . . . . . . . . . . . . . . 382
The java.lang Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
Other API Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
6.9 Focus on Object-Oriented Design: Finding the Classes
and Their Responsibilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
Finding the Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
Identifying a Class’s Responsibilities . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
This Is Only the Beginning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
6.10 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
Review Questions and Exercises   391
Programming Challenges   396

Chapter 7 Arrays and the ArrayList Class   405


7.1 Introduction to Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
Accessing Array Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
Inputting and Outputting Array Contents . . . . . . . . . . . . . . . . . . . . . . . 408
Java Performs Bounds Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
Watch Out for Off-by-One Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
Array Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
Alternate Array Declaration Notation . . . . . . . . . . . . . . . . . . . . . . . . . . 414
x Contents

7.2 Processing Array Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415


Array Length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
The Enhanced for Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
Letting the User Specify an Array’s Size . . . . . . . . . . . . . . . . . . . . . . . . . 419
Reassigning Array Reference Variables . . . . . . . . . . . . . . . . . . . . . . . . . . 421
Copying Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
7.3 Passing Arrays as Arguments to Methods . . . . . . . . . . . . . . . . . . . . . 424
7.4 Some Useful Array Algorithms and Operations . . . . . . . . . . . . . . . . . 428
Comparing Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
Summing the Values in a Numeric Array . . . . . . . . . . . . . . . . . . . . . . . . 429
Getting the Average of the Values in a Numeric Array . . . . . . . . . . . . . . 430
Finding the Highest and Lowest Values in a Numeric Array . . . . . . . . . . 430
The SalesData Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
Partially Filled Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
Working with Arrays and Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
7.5 Returning Arrays from Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
7.6 String Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
Calling String Methods from an Array Element . . . . . . . . . . . . . . . . . . . 445
7.7 Arrays of Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
7.8 The Sequential Search Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
7.9 Two-Dimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452
Initializing a Two-Dimensional Array . . . . . . . . . . . . . . . . . . . . . . . . . . . 456
The length Field in a Two-Dimensional Array . . . . . . . . . . . . . . . . . . . . 457
Displaying All the Elements of a Two-Dimensional Array . . . . . . . . . . . . 459
Summing All the Elements of a Two-Dimensional Array . . . . . . . . . . . . . 459
Summing the Rows of a Two-Dimensional Array . . . . . . . . . . . . . . . . . . 460
Summing the Columns of a Two-Dimensional Array . . . . . . . . . . . . . . . 460
Passing Two-Dimensional Arrays to Methods . . . . . . . . . . . . . . . . . . . . .461
Ragged Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
7.10 Arrays with Three or More Dimensions . . . . . . . . . . . . . . . . . . . . . . . 464
7.11 The Selection Sort and the Binary Search Algorithms . . . . . . . . . . . . . 465
The Selection Sort Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465
The Binary Search Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
7.12 Command-Line Arguments and Variable-Length Argument Lists . . . . 470
Command-Line Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
Variable-Length Argument Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
7.13 The ArrayList Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
Creating and Using an ArrayList Object . . . . . . . . . . . . . . . . . . . . . . . 475
Using the Enhanced for Loop with an ArrayList . . . . . . . . . . . . . . . . . 476
The ArrayList Class’s toString method . . . . . . . . . . . . . . . . . . . . . . . . 477
Removing an Item from an ArrayList . . . . . . . . . . . . . . . . . . . . . . . . . .478
Inserting an Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
Replacing an Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480
Capacity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
Using the Diamond Operator for Type Inference (Java 7) . . . . . . . . . . . . 482
7.14 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
Contents xi

Review Questions and Exercises   483


Programming Challenges   488

Chapter 8 A Second Look at Classes and Objects   495


8.1 Static Class Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495
A Quick Review of Instance Fields and Instance Methods . . . . . . . . . . . . 495
Static Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496
Static Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496
Static Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499
8.2 Passing Objects as Arguments to Methods . . . . . . . . . . . . . . . . . . . . 502
8.3 Returning Objects from Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . 505
8.4 The toString Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507
8.5 Writing an equals Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 511
8.6 Methods That Copy Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514
Copy Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516
8.7 Aggregation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517
Aggregation in UML Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525
Security Issues with Aggregate Classes . . . . . . . . . . . . . . . . . . . . . . . . . 525
Avoid Using null References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527
8.8 The this Reference Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
Using this to Overcome Shadowing . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
Using this to Call an Overloaded Constructor
from Another Constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532
8.9 Enumerated Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
Enumerated Types Are Specialized Classes . . . . . . . . . . . . . . . . . . . . . . . 534
Switching On an Enumerated Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540
8.10 Garbage Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
The finalize Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
8.11 Focus on Object-Oriented Design: Class Collaboration . . . . . . . . . . . 544
Determining Class Collaborations with CRC Cards . . . . . . . . . . . . . . . . . 547
8.12 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548
Review Questions and Exercises   549
Programming Challenges   553

Chapter 9 Text Processing and More


about Wrapper Classes   559
9.1 Introduction to Wrapper Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
9.2 Character Testing and Conversion with the Character Class . . . . . . . 560
Character Case Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
9.3 More String Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568
Searching for Substrings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568
Extracting Substrings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575
Methods That Return a Modified String . . . . . . . . . . . . . . . . . . . . . . . . 579
The Static valueOf Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580
xii Contents

9.4 The StringBuilder Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582


The StringBuilder Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583
Other StringBuilder Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584
The toString Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587
9.5 Tokenizing Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593
9.6 Wrapper Classes for the Numeric Data Types . . . . . . . . . . . . . . . . . . 597
The Static toString Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598
The toBinaryString, toHexString, and toOctalString Methods . . . . . 598
The MIN_VALUE and MAX_VALUE Constants . . . . . . . . . . . . . . . . . . . . . . . 598
Autoboxing and Unboxing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598
9.7 Focus on Problem Solving: The TestScoreReader Class . . . . . . . . . . . 600
9.8 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604
Review Questions and Exercises   605
Programming Challenges   608

Chapter 10 Inheritance   613


10.1 What Is Inheritance? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613
Generalization and Specialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613
Inheritance and the “Is a” Relationship . . . . . . . . . . . . . . . . . . . . . . . . . 614
Inheritance in UML Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 622
The Superclass’s Constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623
Inheritance Does Not Work in Reverse . . . . . . . . . . . . . . . . . . . . . . . . . . 625
10.2 Calling the Superclass Constructor . . . . . . . . . . . . . . . . . . . . . . . . . . 626
When the Superclass Has No Default
or No-Arg Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632
Summary of Constructor Issues in Inheritance . . . . . . . . . . . . . . . . . . . . 633
10.3 Overriding Superclass Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634
Overloading versus Overriding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639
Preventing a Method from Being Overridden . . . . . . . . . . . . . . . . . . . . . 642
10.4 Protected Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643
Package Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 648
10.5 Chains of Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 649
Class Hierarchies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655
10.6 The Object Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655
10.7 Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657
Polymorphism and Dynamic Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . 658
The “Is-a” Relationship Does Not Work in Reverse . . . . . . . . . . . . . . . . . 660
The instanceof Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661
10.8 Abstract Classes and Abstract Methods . . . . . . . . . . . . . . . . . . . . . . . 662
Abstract Classes in UML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668
10.9 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669
An Interface is a Contract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671
Fields in Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675
Implementing Multiple Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675
Interfaces in UML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675
Contents xiii

Default Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 676


Polymorphism and Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678
10.10 Anonymous Inner Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683
10.11 Functional Interfaces and Lambda Expressions . . . . . . . . . . . . . . . . . 686
10.12 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691
Review Questions and Exercises   692
Programming Challenges   698

Chapter 11 Exceptions and Advanced File I/O   703


11.1 Handling Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703
Exception Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704
Handling an Exception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705
Retrieving the Default Error Message . . . . . . . . . . . . . . . . . . . . . . . . . . . 709
Polymorphic References to Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . 712
Using Multiple catch Clauses to Handle Multiple Exceptions . . . . . . . . . 712
The finally Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720
The Stack Trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722
Handling Multiple Exceptions with One catch Clause (Java 7) . . . . . . . . 723
When an Exception Is Not Caught . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725
Checked and Unchecked Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . 726
11.2 Throwing Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 727
Creating Your Own Exception Classes . . . . . . . . . . . . . . . . . . . . . . . . . . 730
Using the @exception Tag in Documentation Comments . . . . . . . . . . . . 733
11.3 Advanced Topics: Binary Files, Random Access Files,
and Object Serialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734
Binary Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734
Random Access Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741
Object Serialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 746
Serializing Aggregate Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 750
11.4 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 751
Review Questions and Exercises   751
Programming Challenges   757

Chapter 12 A First Look at GUI Applications   761


12.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 761
The JFC, AWT, and Swing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 762
Event-Driven Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 764
The javax.swing and java.awt Packages . . . . . . . . . . . . . . . . . . . . . . . 764
12.2 Creating Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 764
Using Inheritance to Extend the JFrame Class . . . . . . . . . . . . . . . . . . . . 767
Equipping GUI Classes with a main Method . . . . . . . . . . . . . . . . . . . . . . 769
Adding Components to a Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 771
Handling Events with Action Listeners . . . . . . . . . . . . . . . . . . . . . . . . . . 777
xiv Contents

Writing an Event Listener for the KiloConverter Class . . . . . . . . . . . . . . 779


Background and Foreground Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 784
The ActionEvent Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 788
12.3 Layout Managers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 793
Adding a Layout Manager to a Container . . . . . . . . . . . . . . . . . . . . . . . 794
The FlowLayout Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 794
The BorderLayout Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 797
The GridLayout Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 804
12.4 Radio Buttons and Check Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 810
Radio Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 810
Check Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 816
12.5 Borders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 821
12.6 Focus on Problem Solving: Extending Classes from JPanel . . . . . . . . 824
The Brandi’s Bagel House Application . . . . . . . . . . . . . . . . . . . . . . . . . . 824
The GreetingPanel Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 825
The BagelPanel Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 826
The ToppingPanel Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 828
The CoffeePanel Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 830
Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 832
12.7 Splash Screens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 836
12.8 Using Console Output to Debug a GUI Application . . . . . . . . . . . . . . 837
12.9 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 842
Review Questions and Exercises   842
Programming Challenges   845

Chapter 13 Advanced GUI Applications   849


13.1 The Swing and AWT Class Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . 849
13.2 Read-Only Text Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 850
13.3 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 852
Selection Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 852
Responding to List Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 853
Retrieving the Selected Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 854
Placing a Border around a List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 858
Adding a Scroll Bar to a List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 858
Adding Items to an Existing JList Component . . . . . . . . . . . . . . . . . . . 863
Multiple Selection Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 863
13.4 Combo Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 868
Retrieving the Selected Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 869
13.5 Displaying Images in Labels and Buttons . . . . . . . . . . . . . . . . . . . . . . 874
13.6 Mnemonics and Tool Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 880
Mnemonics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 880
Tool Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 882
13.7 File Choosers and Color Choosers . . . . . . . . . . . . . . . . . . . . . . . . . . . 882
File Choosers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 883
Color Choosers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 885
Contents xv

13.8 Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 886


13.9 More about Text Components: Text Areas and Fonts . . . . . . . . . . . . . 895
Text Areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 895
Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 898
13.10 Sliders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 899
13.11 Look and Feel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 904
13.12 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 906
Review Questions and Exercises   907
Programming Challenges   912

Chapter 14 Applets and More   917


14.1 Introduction to Applets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 917
14.2 A Brief Introduction to HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 919
Hypertext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 919
Markup Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 920
Document Structure Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 920
Text Formatting Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 922
Creating Breaks in Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 924
Inserting Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 927
14.3 Creating Applets with Swing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 928
Running an Applet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 930
Handling Events in an Applet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 932
14.4 Using AWT for Portability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 937
14.5 Drawing Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 942
The XY Coordinate System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 942
Graphics Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 942
The repaint Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 956
Drawing on Panels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 957
14.6 Handling Mouse Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 963
Handling Mouse Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 963
14.7 Timer Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 973
14.8 Playing Audio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 977
Using an AudioClip Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 978
Playing Audio in an Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 981
14.9 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 982
Review Questions and Exercises   982
Programming Challenges   988

Chapter 15 Creating GUI Applications with JavaFX   991


15.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 991
Event-Driven Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 993
15.2 Stages and Scenes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 993
15.3 Scene Graphs and Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 995
Creating a Scene . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 997
xvi Contents

15.4 Panes and Component Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 999


VBox and HBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 999
Margin and Padding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1001
Nested Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1003
15.5 Events and Event Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1004
Passing Information to Event Handlers . . . . . . . . . . . . . . . . . . . . . . . . 1006
Using Inner Classes for Event Handling . . . . . . . . . . . . . . . . . . . . . . . . 1009
Using Anonymous Local Inner Classes for Event Handling . . . . . . . . . . 1010
Using Lambda Expressions for Event Handling . . . . . . . . . . . . . . . . . . . 1011
15.6 Determining the Target of an Event . . . . . . . . . . . . . . . . . . . . . . . . . 1012
15.7 Radio Buttons and Check Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . 1015
Programming with Check Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1019
Responding to Radio Button and Check Box events . . . . . . . . . . . . . . . 1020
15.8 Displaying Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1020
15.9 Timeline Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1022
15.10 Text Input Controls, Panes, and CSS Styling . . . . . . . . . . . . . . . . . . 1026
Text Input Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1026
Using CSS to Style Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1028
Preferred Width and Height of Components . . . . . . . . . . . . . . . . . . . . . 1029
TilePane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1029
BorderPane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1031
GridPane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1033
Additional Panes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1034
15.11 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1035
Review Questions and Exercises   1035
Programming Challenges   1038

Chapter 16 Recursion   1041


16.1 Introduction to Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1041
16.2 Solving Problems with Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . 1044
Direct and Indirect Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1048
16.3 Examples of Recursive Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1049
Summing a Range of Array Elements with Recursion . . . . . . . . . . . . . . 1049
Drawing Concentric Circles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1050
The Fibonacci Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1052
Finding the Greatest Common Divisor . . . . . . . . . . . . . . . . . . . . . . . . . 1054
16.4 A Recursive Binary Search Method . . . . . . . . . . . . . . . . . . . . . . . . . . 1055
16.5 The Towers of Hanoi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1058
16.6 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1063
Review Questions and Exercises   1063
Programming Challenges   1066

Chapter 17 Sorting, Searching, and Algorithm Analysis   1069


17.1 Introduction to Sorting Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . 1069
The Bubble Sort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1069
Contents xvii

Using the Bubble Sort to Sort Objects . . . . . . . . . . . . . . . . . . . . . . . . . 1075


The Selection Sort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1078
Using the Selection Sort to Sort Objects . . . . . . . . . . . . . . . . . . . . . . . . 1082
The Insertion Sort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1084
Using the Insertion Sort to Sort Objects . . . . . . . . . . . . . . . . . . . . . . . . 1089
The Quicksort Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1090
Using Quicksort to Sort Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1094
17.2 Introduction to Search Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . 1094
The Sequential Search Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1094
Average Case Analysis of the Sequential Search . . . . . . . . . . . . . . . . . . 1097
The Binary Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1097
Efficiency of the Binary Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1101
A Recursive Binary Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1101
17.3  Analysis of Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1105
Computational Problems and Basic Steps . . . . . . . . . . . . . . . . . . . . . . 1106
Complexity of Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1107
Worst Case Complexity of Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . 1108
Average Case Complexity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1109
Asymptotic Complexity and the Big O Notation . . . . . . . . . . . . . . . . . . 1110
17.4 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1114
Review Questions and Exercises   1115
Programming Challenges   1118

Chapter 18 Generics   1121


18.1 Introduction to Generics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1121
Using the Diamond Operator for Type Inference . . . . . . . . . . . . . . . . . 1124
18.2 Writing a Generic Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1124
Only Reference Types Can Be Passed to Type Parameters . . . . . . . . . . . 1129
Instantiating a Generic Class without Specifying a Type Argument . . . . 1130
Commonly Used Type Parameter Names . . . . . . . . . . . . . . . . . . . . . . . 1132
18.3 Passing Objects of a Generic Class to a Method . . . . . . . . . . . . . . . 1132
Constraining a Type Parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1134
Defining a Type Parameter in a Method Header . . . . . . . . . . . . . . . . . 1136
The extends Key Word Constrains a Type to an Upper Bound . . . . . . . 1137
The super Key Word Constrains a Type to a Lower Bound . . . . . . . . . . 1137
18.4 Writing Generic Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1138
18.5 Constraining a Type Parameter in a Generic Class . . . . . . . . . . . . . . 1139
18.6 Inheritance and Generic Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . 1142
18.7 Defining Multiple Type Parameters . . . . . . . . . . . . . . . . . . . . . . . . . 1146
18.8 Generics and Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1149
Constraining a Type Parameter to a Type That Implements
an Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1150
18.9 Erasure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1155
18.10 Restrictions on the Use of Generic Types . . . . . . . . . . . . . . . . . . . . . 1158
xviii Contents

18.11 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1160


Review Questions and Exercises   1161
Programming Challenges   1164

Chapter 19 Collections and the Stream API   1167


19.1 Introduction to the Java Collections Framework . . . . . . . . . . . . . . . 1167
Lists, Sets, and Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1167
Java Functional Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1168
JCF Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1168
Iterating a Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1169
The Iterable Interface and the forEach method . . . . . . . . . . . . . . . . 1169
Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1170
The Enhanced For Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1173
The Collection Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1173
19.2 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1175
The List Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1176
The ArrayList and LinkedList Classes . . . . . . . . . . . . . . . . . . . . . . . 1177
Creating and Initializing Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1178
List Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1179
Methods of the LinkedList Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1182
Using an Interface Variable to Reference a Collection Object . . . . . . . 1183
19.3 Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1185
The Set Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1185
The HashSet Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1185
Implementing Your Own hashCode Method . . . . . . . . . . . . . . . . . . . . . 1190
The LinkedHashSet Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1194
The SortedSet Interface and the TreeSet Class . . . . . . . . . . . . . . . . . 1195
Using a Comparator to Compare Objects . . . . . . . . . . . . . . . . . . . . . . 1198
19.4 Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1200
The HashMap Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1202
The LinkedHashMap Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1208
The SortedMap Interface and the TreeMap Class . . . . . . . . . . . . . . . . . 1210
19.5 The Collections Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1211
19.6 The Stream API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1213
The Stream Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1214
Creating a Stream . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1214
Terminal Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1215
Intermediate Operations on Streams . . . . . . . . . . . . . . . . . . . . . . . . . . 1219
Intermediate Stream Operations are Lazy . . . . . . . . . . . . . . . . . . . . . . 1221
The Stream map Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1223
The Stream reduce Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1224
Stream Collectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1226
19.7 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1231
Review Questions and Exercises   1232
Programming Challenges   1235
Contents xix

Chapter 20 Linked Lists   1237


20.1 Introduction to Linked Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1237
Creating Lists and Adding Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1238
Removing a Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1240
Traversing Linked Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1241
20.2 Operations on Linked Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1244
The isEmpty Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1244
The size Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1245
The add Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1245
The remove Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1246
The toString Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1246
Graphical Interfaces for the Linked List Program . . . . . . . . . . . . . . . . . 1252
20.3 Doubly-Linked and Circularly-Linked Lists . . . . . . . . . . . . . . . . . . . . 1259
Adding a Node to a Doubly-Linked List . . . . . . . . . . . . . . . . . . . . . . . . 1260
Removing a Node from a Doubly-Linked List . . . . . . . . . . . . . . . . . . . . 1261
Circularly-Linked Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1268
20.4 Recursion on Linked Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1268
A Recursive Implementation of size . . . . . . . . . . . . . . . . . . . . . . . . . . 1269
A Recursive Implementation of the add(String e,
Node list) Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1270
A Recursive Implementation of add(int index, String e,
Node list) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1270
A Recursive Implementation of the remove Methods . . . . . . . . . . . . . . .1271
20.5 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1283
Review Questions and Exercises   1283
Programming Challenges   1286

Chapter 21 Stacks and Queues   1289


21.1 Stacks and Their Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1289
Examples and Applications of Stacks . . . . . . . . . . . . . . . . . . . . . . . . . . 1289
Stack Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1290
Stacks of Primitive Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1291
21.2 Array Implementation of Stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1292
The Stack Push Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1293
The Stack empty Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1293
The Stack peek and pop Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1293
Stacks of Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1297
21.3 Linked Implementation of Stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . 1298
Implementation of Stack Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1299
21.4 Queues and Their Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1303
21.5 Array Implementation of Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . 1303
GUI Front Ends for the Queue Demo Program . . . . . . . . . . . . . . . . . . . 1310
Swing Version of the GUI Front End . . . . . . . . . . . . . . . . . . . . . . . . . . . 1311
JavaFX Version of the GUI Front End . . . . . . . . . . . . . . . . . . . . . . . . . . 1314
xx Contents

21.6 Linked List Implementation of Queues . . . . . . . . . . . . . . . . . . . . . . . 1317


Queue Initialization and Enqueuing of Items . . . . . . . . . . . . . . . . . . . . 1317
Dequeuing Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1318
21.7 Generic Implementation of Stacks and Queues . . . . . . . . . . . . . . . . 1322
21.8 Queues and Breadth-First Search . . . . . . . . . . . . . . . . . . . . . . . . . . . 1325
21.9 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1328
Review Questions and Exercises   1329
Programming Challenges   1331

Chapter 22 Binary Trees, AVL Trees, and Priority Queues   1335


22.1 Binary Trees and Their Applications . . . . . . . . . . . . . . . . . . . . . . . . . 1335
Binary Tree Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1336
Applications of Binary Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1337
Representing Nodes of Binary Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . 1337
Traversing a Binary Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1338
Graphical Display of Binary Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1341
Graphical Display of Binary Trees Using Swing . . . . . . . . . . . . . . . . . . 1342
Graphical Display of Binary Trees Using JavaFX . . . . . . . . . . . . . . . . . 1344
Class Implementation of Binary Trees . . . . . . . . . . . . . . . . . . . . . . . . . 1347
22.2 Binary Search Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1347
Adding a Value to a Binary Search Tree . . . . . . . . . . . . . . . . . . . . . . . . 1349
Removing a Value from a Binary Search Tree . . . . . . . . . . . . . . . . . . . . 1349
Implementation of Binary Search Trees . . . . . . . . . . . . . . . . . . . . . . . . 1353
Graphical Display of Binary Search Trees . . . . . . . . . . . . . . . . . . . . . . . 1358
A Program for Testing the Binary Search Tree Class . . . . . . . . . . . . . . . 1360
22.3 AVL Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1368
Adding New Elements to AVL Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . 1369
Implementation of AVL Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1372
22.4 Priority Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1380
Applications of Priority Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1382
Using Comparators with Priority Queues . . . . . . . . . . . . . . . . . . . . . . . 1383
Analysis of Heapsort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1385
Implementation of Priority Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . 1385
Binary Trees with the Heap Order Property . . . . . . . . . . . . . . . . . . . . . 1385
Complete Binary Trees and Heaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1386
The Depth of Complete Binary Trees . . . . . . . . . . . . . . . . . . . . . . . . . . 1387
Storing a Complete Binary Tree in an Array . . . . . . . . . . . . . . . . . . . . . 1387
Adding an Item to a Heap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1388
Removing the Minimum Element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1389
22.5 Common Errors to Avoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1397
Review Questions and Exercises   1397
Programming Challenges   1401

Index    1501
Contents xxi

Companion Website:
Chapter 23 Databases
Appendix A Working with Records and Random Access Files
Appendix B The ASCII/Unicode Characters
Appendix C Operator Precedence and Associativity
Appendix D Java Key Words
Appendix E Installing the JDK and JDK Documentation
Appendix F Using the javadoc Utility
Appendix G More about the Math Class
Appendix H Packages
Appendix I More about JOptionPane Dialog Boxes
Appendix J Answers to Checkpoints
Appendix K Answers to Odd-Numbered Review Questions
Appendix L Getting Started with Alice
Appendix M Configuring JavaDB
Case Study 1 Calculating Sales Commission
Case Study 2 The Amortization Class
Case Study 3 The PinTester Class
Case Study 4 Parallel Arrays
Case Study 5 The FeetInches Class
Case Study 6 The SerialNumber Class
Case Study 7 A Simple Text Editor Application
This page intentionally left blank
Location of Videonotes in the Text
VideoNote

Chapter 1 Compiling and Running a Java Program, p. 14


Using an IDE, p. 15
Your First Java Program, p. 25

Chapter 2 Displaying Console Output, p. 33


Declaring Variables, p. 39
Simple Math Expressions, p. 55
The Miles-per-Gallon Problem, p. 106

Chapter 3 The if Statement, p. 111


The if-else Statement, p. 121
The if-else-if Statement, p. 132
The Time Calculator Problem, p. 185

Chapter 4 The while Loop, p. 193


The Pennies for Pay Problem, p. 263

Chapter 5 Passing Arguments to a Method, p. 279


Returning a Value from a Method, p. 293
The Retail Price Calculator Problem, p. 312

Chapter 6 Writing Classes and Creating Objects, p. 327


Initializing an Object with a Constructor, p. 348
The Personal Information Class Problem, p. 397

Chapter 7 Accessing Array Elements in a Loop, p. 409


Passing an Array to a Method, p. 424
The Charge Account Validation Problem, p. 489

Chapter 8 Returning Objects from Methods, p. 505


Aggregation, p. 517
The BankAccount, Class Copy Constructor Problem, p. 554

Chapter 9 The Sentence Capitalizer Problem, p. 608

Chapter 10 Inheritance, p. 613


Polymorphism, p. 657
The Employee and Productionworker Classes Problem, p. 698

Chapter 11 Handling Exceptions, p.703


The Exception Project Problem, p. 759

(continued on the next page)


LOCATION OF VIDEONOTES IN THE TEXT (continued)
VideoNote
Chapter 12 Creating a Simple GUI Application, p. 764
Handling Events, p. 777
The Monthly Sales Tax Problem, p. 846

Chapter 13 The JList Component, p. 852


The JComboBox Component, p. 868
The Image Viewer Problem, p. 912

Chapter 14 Creating an Applet, p. 929


The House Applet Problem, p. 988

Chapter 15 Nested Layouts 2, p. 1038

Chapter 16 Reducing a Problem with Recursion, p. 1045


The Recursive Power Problem, p. 1067

Chapter 17 The Bubble Sort Algorithm, p. 1069


Searching for Objects with the Binary Search Algorithm, p. 1118

Chapter 18 Inheritance and Generic classes, p. 1142


Highest and Lowest Elements, p. 1165

Chapter 19 The HashMap Class, p. 1202

Chapter 20 Adding a Node to a Doubly-Linked List, p. 1260


Recursive Linked List Operations, p. 1287

Chapter 21 Array Implementation of Queues, p. 1303


Array-Based Deque, p. 1332

Chapter 22 Removing a Value from a Binary Search Tree, p. 1349


Prefix Calculator, p. 1402
Other documents randomly have
different content
I had gathered at the time of this finding of the Boma High Court that
steps had then been taken to make it everywhere effective and to insure
obedience to the law in this respect, and that a recurrence of the illegalities
brought to light in the Mongala region had been rendered impossible in any
part of the Congo State. From what I saw during the few days spent in the
A.B.I.R. Concession, and again outside its limits in the Lower Lulongo, it
seemed to be clear that the action taken by the authorities nearly three years
ago could not have produced the results undoubtedly then desired.
On my leaving Bongandanga on the 3rd September I returned down the
Lopori and Lulongo Rivers, arriving at J**. The following day, about 9 at
night, some natives of the neighbourhood came to see me, bringing with
them a lad of about 16 years of age whose right hand was missing. His name
was X and his relatives said they came from K**, a village on the opposite
side of the river some few miles away. As it was late at night there was some
difficulty in obtaining a translation of their statements, but I gathered that
X’s hand had been cut off in K** by a sentry of the La Lulanga Company,
who was, or had been, quartered there. They said that this sentry, at the time
that he had mutilated X, had also shot dead one of the chief men of the town.
X, in addition to this mutilation, had been shot in the shoulder blade, and, as
a consequence, was deformed. On being shot it was said he had fallen down
insensible, and the sentry had then cut off his hand, alleging that he would
take it to the Director of the Company at Mampoko. When I asked if this
had been done the natives replied that they believed that the hand had only
been carried part of the way to Mampoko and then thrown away. They did
not think the white man had seen it. They went on to say that they had not
hitherto made any complaint of this. They declared they had seen no good
object in complaining of a case of this kind since they did not hope any good
would result to them. They then went on to say that a younger boy than X, at
the beginning of this year (as near as they could fix the date at either the end
of January or the beginning of February), had been mutilated in a similar
way by a sentry of the same trading Company, who was still quartered in
their town, and that when they had wished to bring this latter victim with
them the sentry had threatened to kill him and that the boy was now in
hiding. They begged that I would myself go back with them to their village
and ascertain that they were speaking the truth. I thought it my duty to listen
to this appeal, and decided to return with them on the morrow to their town.
In the morning, when about to start for K**, many people from the
surrounding country came in to see me. They brought with them three
individuals who had been shockingly wounded by gun fire, two men and a
very small boy, not more than 6 years of age, and a fourth—a boy child of 6
or 7—whose right hand was cut off at the wrist. One of the men, who had
been shot through the arm, declared that he was Y of L**, a village situated
some miles away. He declared that he had been shot as I saw under the
following circumstances: the soldiers had entered his town, he alleged, to
enforce the due fulfilment of the rubber tax due by the community. These
men had tied him up and said that unless he paid 1,000 brass rods to them
they would shoot him. Having no rods to give them they had shot him
through the arm and had left him. The soldiers implicated he said were four
whose names were given me. They were, he believed, all employés of the La
Lulanga Company and had come from Mampoko. At the time when he, Y,
was shot through the arm the Chief of his town came up and begged the
soldiers not to hurt him, but one of them, a man called Z, shot the Chief
dead. No white man was with these sentries, or soldiers, at the time. Two of
them, Y said, he believed had been sent or taken to Coquilhatville. Two of
them—whom he named—he said were still at Mampoko. The people of L**
had sent to tell the white man at Mampoko of what his soldiers had done. He
did not know what punishment, if any, the soldiers had received, for no
inquiry had since been made in L**, nor had any persons in that town been
required to testify against their aggressors. This man was accompanied by
four other men of his town. These four men all corroborated Y’s statement.
These people were at once followed by two men of M**, situated, they
said, close to K**, and only a few miles distant. They brought with them a
full-grown man named A A, whose arm was shattered and greatly swollen
through the discharge of a gun, and a small boy named B B, whose left arm
was broken in two places from two separate gun shots—the wrist being
shattered and the hand wobbling about loose and quite useless. The two men
made the following statement: That their town, like all the others in the
neighbourhood, was required to furnish a certain quantity of india-rubber
fortnightly to the head-quarters of the La Lulanga Company at Mampoko;
that at the time these outrages were committed, which they put at less than a
year previously, a man named C C was a sentry of that Company quartered
in their village; that they two now before me had taken the usual fortnight’s
rubber to Mampoko. On returning to M** they found that C C, the sentry,
had shot dead two men of the town named D D and E E, and had tied up this
man A A and the boy B B, now before me, to two trees. The sentry said that
this was to punish the two men for having taken the rubber to Mampoko
without having first shown it to him and paid him a commission on it. The
two men asserted that they had at once returned to Mampoko, and had
begged the Director of the Company to return with them to M** and see
what his servants had done. But, they alleged, he had refused to comply with
their request. On getting back to their town they then found that the man A A
and the child B B were still tied to the trees, and had been shot in the arms
as I now saw. On pleading with the sentry to release these two wounded
individuals, he had required a payment of 2,000 brass rods (100 fr.). One of
the two men stayed to collect this money, and another returned to Mampoko
to again inform the Director of what had been done. The two men declared
that nothing was done to the sentry C C, but that the white man said that if
the people behaved badly again he was to punish them. The sentry C C, they
declared, remained some time longer in M**, and they do not now know
where he is.
These people were immediately followed by a number of natives who
came before me bringing a small boy of not more than 7 years of age, whose
right hand was gone at the wrist. This child, whose name was F F, they had
brought from the village of N**. They stated that some years ago (they
could not even approximately fix the date save by indicating that F F was
only just able to run) N** had been attacked by several sentries of the La
Lulanga Company. This was owing to their failure in supplying a sufficiency
of india-rubber. They did not know whether these sentries had been sent by
any European, but they knew all their names, and the Chief of them was one
called G G. G G had shot dead the Chief of their town, and the people had
run into the forest. The sentries pursued them, and G G had knocked down
the child F F with the butt of his gun and had then cut off his hand. They
declared that the hand of the dead man and of this boy F F had then been
carried away by the sentries. The sentries who did this belonged to the La
Lulanga Company’s factory at O**. The man who appeared with F F went
on to say that they had never complained about it, save to the white man
who had then been that Company’s agent at O**. They had not thought of
complaining to the Commissaire of the district. Not only was he far away,
but they were afraid they would not be believed, and they thought the white
men only wished for rubber, and that no good could come of pleading with
them.
At the same time a number of men followed, with the request that I
would listen to them. W declared that their town P**, which had formerly
been on the north bank of the X** River (where I had myself seen it), had
now been transferred by force to the south bank, close to the factory at Q**.
He said that this act of compulsory transference was the direct act of the
Commissaire-Général of the ... district. The Commissaire had visited P** on
his steamer, and had ordered the people of that town to work daily at Q**
for the La Lulanga factory. W had replied that it was too far for the women
of P** to go daily to Q** as was required; but the Commissaire, in reply,
had taken fifty women and carried them away with him. The women were
taken to Q**. Two men were taken at the same time. To get these women
back, W went on to say, he and his people had to pay a fine of 10,000 brass
rods (500 fr.). They had paid this money to the Commissaire-Général
himself. They had then been ordered by the Commissaire to abandon their
town, since it lay too far from the factory, and build a fresh town close to
Q**, so that they might be at hand for the white man’s needs. This they had
been forced to do—many of them were taken across by force. It was about
two years ago W thought that this deportation had been effected, and they
now came to beg that I would use my influence with the local authorities to
permit their return to their abandoned home. Where they were now situated
close to Q** they were most unhappy, and they only desired to be allowed
to return to the former site of P**. They have to take daily to Q** the
following:—
10 baskets gum-copal.
1,000 long canes (termed “ngodji”), which grow in the swamps, and are
used in thatching and roofing.
500 bamboos for building.
Each week they are required to deliver at the factory—
200 rations of kwanga.
120 rations of fish.
In addition, fifty women are required each morning to go to the factory
and work there all day. They complained that the remuneration given for
these services was most inadequate, and that they were continually beaten.
When I asked the Chief W why he had not gone to D F to complain if the
sentries beat him or his people, opening his mouth he pointed to one of the
teeth which was just dropping out, and said: “That is what I got from the D
F four days ago when I went to tell him what I now say to you.” He added
that he was frequently beaten, along with others of his people, by the white
man.
One of the men with him, who gave his name as H H, said that two
weeks ago the white man at Q** had ordered him to serve as one of the
porters of his hammock on a journey he proposed taking inland. H H was
then just completing the building of a new house, and excused himself on
this ground, but offered to fetch a friend as a substitute. The Director of the
Company had, in answer to this excuse, burnt down his house, alleging that
he was insolent. He had had a box of cloth and some ducks in the house—in
fact, all his goods, and they were destroyed in the fire. The white man then
caused him to be tied up, and took him with him inland, and loosed him
when he had to carry the hammock.
Other people were waiting, desirous of speaking with me, but so much
time was taken in noting the statements already made that I had to leave, if I
hoped to reach K** at a reasonable hour. I proceeded in a canoe across the
Lulongo and up a tributary to a landing-place which seemed to be about ...
miles from I**. Here, leaving the canoes, we walked for a couple of miles
through a flooded forest to reach the village. I found here a sentry of the La
Lulanga Company and a considerable number of natives. After some little
delay a boy of about 15 years of age appeared, whose left arm was wrapped
up in a dirty rag. Removing this, I found the left hand had been hacked off
by the wrist, and that a shot hole appeared in the fleshy part of the forearm.
The boy, who gave his name as I I, in answer to my inquiry, said that a
sentry of the La Lulanga Company now in the town had cut off his hand. I
proceeded to look for this man, who at first could not be found, the natives
to a considerable number gathering behind me as I walked through the town.
After some delay the sentry appeared, carrying a cap-gun. The boy, whom I
placed before him, then accused him to his face of having mutilated him.
The men of the town, who were questioned in succession, corroborated the
boy’s statement. The sentry, who gave his name as K K, could make no
answer to the charge. He met it by vaguely saying some other sentry of the
Company had mutilated I I; his predecessor, he said, had cut off several
hands, and probably this was one of the victims. The natives around said that
there were two other sentries at present in the town, who were not so bad as
K K, but that he was a villain. As the evidence against him was perfectly
clear, man after man standing out and declaring he had seen the act
committed, I informed him and the people present that I should appeal to the
local authorities for his immediate arrest and trial. In the course of my
interrogatory several other charges transpired against him. These were of a
minor nature, consisting of the usual characteristic acts of blackmailing,
only too commonly reported on all sides. One man said that K K had tied up
his wife and only released her on payment of 1,000 rods. Another man said
that K K had robbed him of two ducks and a dog. These minor offences K K
equally demurred to, and again said that I I had been mutilated by some
other sentry, naming several. I took the boy back with me and later brought
him to Coquilhatville, where he formally charged K K with the crime,
alleging to the Commandant, who took his statement, through a special
Government interpreter, in my presence, that it had been done “on account
of rubber.” I have since been informed that, acting on my request, the
authorities at Coquilhatville had arrested K K, who presumably will be tried
in due course. A copy of my notes taken in K**, where I I charged K K
before me, is appended (Inclosure 6).[18]
It was obviously impossible that I should visit all the villages of the
natives who came to beg me to do so at J** or elsewhere during my journey,
or to verify on the spot, as in the case of the boy, the statements they made.
In that one case the truth of the charges preferred was amply demonstrated,
and their significance was not diminished by the fact that, whereas this act
of mutilation had been committed within a few miles of Q**, the head-
quarters of a European civilizing agency, and the guilty man was still in their
midst, armed with the gun with which he had first shot his victim (for which
he could produce no licence when I asked for it, saying it was his
employers’), no one of the natives of the terrorized town had attempted to
report the occurrence. They had in the interval visited Mampoko each
fortnight with the india-rubber from their district. There was also in their
midst another mutilated boy X, whose hand had been cut off either by this or
another sentry. The main waterway of the Lulongo River lay at their doors,
and on it well nigh every fortnight a Government steamer had passed up and
down stream on its way to bring the india-rubber of the A.B.I.R. Company
to Coquilhatville. They possessed, too, some canoes; and, if all other
agencies of relief were closed, the territorial tribunal at Coquilhatville lay
open to them, and the journey to it down stream from their village could
have been accomplished in some twelve hours. It was no greater journey,
indeed, than many of the towns I had elsewhere visited were forced to
undertake each week or fortnight to deliver supplies to their local tax
collectors. The fact that no effort had been made by these people to secure
relief from their unhappy situation impelled me to believe that a very real
fear of reporting such occurrences actually existed among them. That
everything asserted by such a people, under such circumstances, is strictly
true I should in no wise assert. That discrepancies must be found in much
alleged by such rude savages, to one whose sympathies they sought to
awaken, must equally be admitted. But the broad fact remained that their
previous silence said more than their present speech. In spite of
contradictions, and even seeming misstatements, it was clear that these men
were stating either what they had actually seen with their eyes or firmly
believed in their hearts. No one viewing their unhappy surroundings or
hearing their appeals, no one at all cognizant of African native life or
character, could doubt that they were speaking, in the main, truly; and the
unhappy conviction was forced upon me that in the many forest towns
behind the screen of trees, which I could not visit, these people were entitled
to expect that a civilized administration should be represented among them
by other agents than the savages euphemistically termed “forest guards.”
The number of these “forest guards” employed in the service of the
various Concession Companies on the Congo must be very considerable; but
it is not only the Concession Companies which employ “forest guards,” for I
found many of these men in the service of the La Lulanga Company, which
is neither a Concession Company nor endowed with any “rights of police,”
so far as I am aware. In the A.B.I.R. Concession there must be at least
twenty stations directed by one or more European agents.
Each one of these “factories” has, with the permission of the
Government, an armament of twenty-five rifles. According to this estimate
of the A.B.I.R. factories, and adding the armament of the two steamers that
Company possesses, it will be found that this one Concession Company
employs 550 rifles, with a supply of cartridges not, I believe, as yet legally
fixed. These rifles are supposed by law not to be taken from the limits of the
factories, whereas the “sentries” or “forest guards” are quartered in well-
nigh every rubber-producing village of the entire Concession.
These men are each armed with a cap-gun, and the amount of
ammunition they may individually expend would seem to have no legal
limits. These cap-guns can be very effective weapons. On the Lower
Lulongo I bought the skin of a fine leopard from a native hunter who had
shot the animal the previous day. He produced a cap-gun and his
ammunition for my inspection, and I learned from all the men around him
that he alone had killed the beast with his own gun. This gun, he informed
me, he had purchased some years ago from a former Commissaire of the
Government at Coquilhatville, whose name he gave me.
It would be, I think, a moderate computation to put the number of cap-
guns issued by the A.B.I.R. Company to its “sentries” as being in the
proportion of six to one to the number of rifles allowed to each factory.
These figures could be easily verified, but whatever the proportion may be
of cap-guns to rifles, it is clear that the A.B.I.R. Society alone controls a
force of some 500 rifles and a very large stock of cap-guns.
The other Concession Companies on the Congo have similar privileges,
so that it might not be an excessive estimate to say that these Companies and
the subsidiary ones (not enjoying rights of police) between them, direct an
armed force of not less than 10,000 men.
Their “rights of police,” by the Circular of Governor-General Wahis of
October 1900, were seemingly limited to the right to “requisition” the
Government forces in their neighbourhood to maintain order within the
limits of the Concession. That Circular, while it touched upon the arming of
“Kapitas” with cap-guns, did not clearly define the jurisdiction of these men
as a police force or their use of that weapon, but it is evident that the
Government has been cognizant of, and is responsible for, the employment
of these armed men. By a Royal Decree, dated the 10th March, 1892, very
clear enactments were promulgated dealing with the use of all fire-arms
other than flint-locks. By the terms of this Decree all fire-arms and their
munitions, other than flint-lock guns, were required, immediately upon
importation, to be deposited in a depôt or private store placed under the
control of the Government. Each weapon imported had to be registered upon
its entry into the depôt and marked under the supervision of the
Administration, and could not be withdrawn thence save on the presentation
of a permit to carry arms. These permits to carry arms were liable each to a
tax of 20 fr., and could be withdrawn in case of abuse. By an Ordinance of
the Governor-General of the Congo State, dated the 16th June, 1892, various
Regulations making locally effective the foregoing Decree were published.
It is clear that the responsibility for the extensive employment of men armed
with cap-guns by the various commercial Companies on the Upper Congo
rests with the governing authority, which either by law permitted it or did
not make effective its own laws.
The six natives brought before me at I** had all of them been wounded
by gun-fire, and the guns in question could only have come into the hands of
their assailants through the permission or the neglect of the authorities. Two
of these injured individuals were children—one of them certainly not more
than 7 years of age—and the other a child (a boy of about the same age),
whose arm was shattered by gun-fire at close quarters. Whatever truth there
might be in the direct assertions of these people and their relatives, who
attested that the attacks upon them had been made by sentries of the La
Lulanga Company, it was clear that they had all been attacked by men using
guns, which a law already eleven years old had clearly prohibited from
being issued, save in special cases, and “to persons who could offer
sufficient guarantee that the arms and the munitions which should be
delivered to them would not be given, ceded, or sold to third parties”—and,
moreover, under a licence which could at any time be withdrawn.
Three of these injured individuals, subsequent to the initial attack upon
them, had had their hands cut off—in each case, as it was alleged to me, by a
sentry of the La Lulanga Company. In the one case I could alone personally
investigate—that of the boy I I—I found this accusation proved on the spot,
without seemingly a shadow of doubt existing as to the guilt of the accused
sentry. These six wounded and mutilated individuals came from villages in
the immediate vicinity of I**, and both from their lips and from those of
others who came to me from a greater distance it was clear that these were
not the only cases in that neighbourhood. One man, coming from a village
20 miles away, begged me to return with him to his home, where, he
asserted, eight of his fellow-villagers had recently been killed by sentries
placed there in connection with the fortnightly yield of india-rubber. But my
stay at I** was necessarily a brief one. I had not time to do more than visit
the one village of R** and in that village I had only time to investigate the
charge brought by I I. The country is, moreover, largely swampy forest, and
the difficulties of getting through it are very great. A regularly equipped
expedition would have been needed, and the means of anything like an
exhaustive inquiry were not at my disposal. But it seemed painfully clear to
me that the facts brought to my knowledge in a three days’ stay at I** would
amply justify the most exhaustive inquiry being made into the employment
of armed men in that region, and the use to which they put the weapons
intrusted to them—ostensibly as the authorized dependants of commercial
undertakings. From what I had observed in the A.B.I.R. Concession it is
equally clear to me that no inquiry could be held to have been exhaustive
which did not embrace the territories of that Company also.
The system of quartering Government soldiers in the villages, once
universal, has to-day been widely abandoned; but the abuses once prevalent
under this head spring to life in this system of “forest guards,” who, over a
wide area, represent the only form of local gendarmerie known. But that the
practice of employing Government native soldiers in isolated posts has not
disappeared is admitted by the highest authorities.
A Circular on this subject, animadverting on the disregard of the
reiterated instructions issued, which had forbidden the employment of black
troops unaccompanied by a European officer, was dispatched by the
Governor-General as recently as the 7th September, 1903, during the period
I was actually on the Upper Congo. In this Circular the Commandants and
officers of the Force Publique are required to rigorously observe the oft-
repeated instructions on this head, and it is pointed out that, in spite of the
most imperative orders forbidding the employment of black soldiers by
themselves on the public service—“on continue en maints endroits à
pratiquer ce déplorable usage.” Copy of this Circular is appended (Inclosure
7).[19]
From my observation of the districts I travelled on in the Upper Congo, it
would seem well-nigh impossible for European officers to be always with
the soldiers who may be sent on minor expeditions. The number of officers
is limited; they have much to do in drilling their troops, and in camp and
station life, while the territory to be exploited is vast. The ramifications of
the system of taxation, outlined in the foregoing sketch of it, show it to be of
a wide-spread character, and since a more or less constant pressure has to be
exercised to keep the taxpayers up to the mark, and over a very wide field, a
certain amount of dependance upon the uncontrolled actions of native
soldiers (who are the only regular police in the country) must be permitted
those responsible for the collection of the tax. The most important article of
native taxation in the Upper Congo is unquestionably rubber, and to
illustrate the importance attaching by their superiors to the collection and
augmentation of this tax, the Circular of Governor-General Wahis, addressed
to the Commissionaires de District and Chefs de Zône on the 29th March,
1901, was issued. A copy of that Circular is attached (Inclosure 8).[20]
The instructions this Circular conveys would be excellent if coming from
the head of a trading house to his subordinates, but addressed, as they are,
by a Governor-General to the principal officers of his administration, they
reveal a somewhat limited conception of public duty. Instead of their
energies being directed to the government of their districts, the officers
therein addressed could not but feel themselves bound to consider the
profitable exploitation of india-rubber as one of the principal functions of
Government. Taken into account the interpretation these officials must put
upon the positive injunctions of their chief, there can be little doubt that they
would look upon the profitable production of india-rubber as among the
most important of their duties. The praiseworthy official would be he whose
district yielded the best and biggest supply of that commodity; and,
succeeding in this, the means whereby he brought about the enhanced value
of that yield would not, it may be believed, be too closely scrutinized.
When it is remembered that the reprimanded officials are the
embodiment of all power in their districts, and that the agents they are
authorized to employ are an admittedly savage soldiery, the source whence
spring the unhappiness and unrest of the native communities I passed
through on the Upper Congo need not be sought far beyond the policy
dictating this Circular.
I decided, owing to pressure of other duties, to return from Coquilhatville
to Stanley Pool. The last incident of my stay in the Upper Congo occurred
on the night prior to my departure. Late that night a man came with some
natives of the S** district, represented as his friends, who were fleeing from
their homes, and whom he begged me to carry with me to the French
territory at Lukolela. These were L L of T** and seven others. L L stated
that, owing to his inability to meet the impositions of the Commissaire of the
S** district, he had, with his family, abandoned his home, and was seeking
to reach Lukolela. He had already come 80 miles down stream by canoe, but
was now hiding with friends in one of the towns near Coquilhatville. Part of
the imposition laid upon his town consisted of two goats, which had to be
supplied each month for the white man’s table at S**. As all the goats in his
neighbourhood had long since disappeared in meeting these demands, he
could now only satisfy this imposition by buying in inland districts such
goats as were for sale. For these he had to pay 3,000 rods each (150 fr.), and
as the Government remuneration amounted to only 100 rods (5 fr.) per goat,
he had no further means of maintaining the supply. Having appealed in vain
for the remission of this burden, no other course was left him but to fly. I
told this man I regretted I could not help him, that his proper course was to
appeal for relief to the authorities of the district; and this failing, to seek the
higher authorities at Boma. This, he said, was clearly impossible for him to
do. On the last occasion when he had sought the officials at S**, he had
been told that if his next tax were not forthcoming he should go into the
“chain gang.” He added that a neighbouring Chief who had failed in this
respect had just died in the prison gang, and that such would be his fate if he
were caught. He added that, if I disbelieved him, there were those who could
vouch for his character and the truth of his statement; and I told him and his
friend that I should inquire in that quarter, but that it was impossible for me
to assist a fugitive. I added, however, that there was no law on the Congo
Statute Book which forbade him or any other man from travelling freely to
any part of the country, and his right to navigate in his canoe the Upper
Congo was as good as mine in my steamer or any one else’s. He and his
people left me at midnight, saying that unless they could get away with me
they did not think it possible they could succeed in gaining Lukolela. A
person at T**, to whom I referred this statement, informed me that L L’s
statement was true. He said: What L L told you, re price of goats, was
perfectly true. At U** they are 3,000, and here they are 2,500 to 3,000 rods.
Ducks are from 200 to 300 rods. Fowls are from 60 to 100 rods. Re “dying
in the chains,” he had every reason to fear this, for recently two Chiefs died
in the chain, viz., the Chief of a little town above U**; his crime: because he
did not move his houses a few hundred yards to join them to ... as quickly as
the Commissaire thought he should do. Second, the Chief of T**; crime:
because he did not go up every fortnight with the tax. These two men were
chained together and made to carry heavy loads of bricks and water, and
were frequently beaten by the soldiers in charge of them. There are
witnesses to prove this.
Leaving the township of Coquilhatville on the 11th September, I reached
Stanley Pool on the 15th September.
I have, &c.
(Signed) R. CASEMENT.
Inclosure 1 in No. 3.
(See p. 29.)
Notes on Refugee Tribes encountered in July 1903.
Hearing of the L* refugees from I*, I decided to visit the nearest
Settlement of these fugitives, some 20 miles away, to see them for myself.
At N* found large town of K*, and scattered through it many small
settlements of L* refugees. The town of N* consists approximately of
seventy-one K* houses, and seventy-three occupied by L*. These latter
seemed industrious, simple folk, many weaving palm fibre into mats or
native cloth; others had smithies, working brass wire into bracelets, chains,
and anklets; some iron-workers making knives. Sitting down in one of these
blacksmith’s sheds, the five men at work ceased and came over to talk to us.
I counted ten women, six grown-up men, and eight lads and women in this
one shed of L*. I then asked them to tell me why they had left their homes.
Three of the men sat down in front of me, and told a tale which I cannot
think can be true, but it seemed to come straight from their hearts. I
repeatedly asked certain parts to be gone over again while I wrote in my
note-book. The fact of my writing down and asking for names, &c., seemed
to impress them, and they spoke with what certainly impressed me as being
great sincerity.
I asked, first, why they had left their homes, and had come to live in a
strange far-off country among the K*, where they owned nothing, and were
little better than servitors. All, when this question was put, women as well,
shouted out, “On account of the rubber tax levied by the Government posts.”
I asked particularly the names of the places whence they had come. They
answered they were from V**. Other L* refugees here at N* were W**,
others again were X**, but all had fled from their homes for the same reason
—it was the “rubber tax.”
I asked then how this tax was imposed. One of them, who had been
hammering out an iron neck collar on my arrival, spoke first. He said:—
“I am N N. These other two beside me are O O and P P, all of us Y**.
From our country each village had to take twenty loads of rubber. These
loads were big: they were as big as this....” (Producing an empty basket
which came nearly up to the handle of my walking-stick.) “That was the first
size. We had to fill that up, but as rubber got scarcer the white man reduced
the amount. We had to take these loads in four times a-month.”
Q. “How much pay did you get for this?”
A. (Entire audience.) “We got no pay! We got nothing!”
And then N N, whom I asked, again said:—
“Our village got cloth and a little salt, but not the people who did the
work. Our Chiefs eat up the cloth; the workers got nothing. The pay was a
fathom of cloth and a little salt for every big basket full, but it was given to
the Chief, never to the men. It used to take ten days to get the twenty baskets
of rubber—we were always in the forest and then when we were late we
were killed. We had to go further and further into the forest to find the
rubber vines, to go without food, and our women had to give up cultivating
the fields and gardens. Then we starved. Wild beasts—the leopards—killed
some of us when we were working away in the forest, and others got lost or
died from exposure and starvation, and we begged the white man to leave us
alone, saying we could get no more rubber, but the white men and their
soldiers said: ‘Go! You are only beasts yourselves, you are nyama (meat).’
We tried, always going further into the forest, and when we failed and our
rubber was short, the soldiers came to our towns and killed us. Many were
shot, some had their ears cut off; others were tied up with ropes around their
necks and bodies and taken away. The white men sometimes at the posts did
not know of the bad things the soldiers did to us, but it was the white men
who sent the soldiers to punish us for not bringing in enough rubber.”
Here P P took up the tale from N N:—
“We said to the white men, ‘We are not enough people now to do what
you want us. Our country has not many people in it and we are dying fast.
We are killed by the work you make us do, by the stoppage of our
plantations, and the breaking up of our homes.’ The white man looked at us
and said: ‘There are lots of people in Mputu’ ” (Europe, the white man’s
country). “ ‘If there are lots of people in the white man’s country there must
be many people in the black man’s country.’ The white man who said this
was the chief white man at F F*, his name was A B, he was a very bad man.
Other white men of Bula Matadi who had been bad and wicked were B C, C
D, and D E.” “These had killed us often, and killed us by their own hands as
well as by their soldiers. Some white men were good. These were E F, F G,
G H, H I, I K, K L.”
These ones told them to stay in their homes and did not hunt and chase
them as the others had done, but after what they had suffered they did not
trust more any one’s word, and they had fled from their country and were
now going to stay here, far from their homes, in this country where there
was no rubber.
Q. “How long is it since you left your homes, since the big trouble you
speak of?”
A. “It lasted for three full seasons, and it is now four seasons since we
fled and came into the K* country.”
Q. “How many days is it from N* to your own country?”
A. “Six days of quick marching. We fled because we could not endure the
things done to us. Our Chiefs were hanged, and we were killed and starved
and worked beyond endurance to get rubber.”
Q. “How do you know it was the white men themselves who ordered
these cruel things to be done to you? These things must have been done
without the white man’s knowledge by the black soldiers.”
A. (P P): “The white men told their soldiers: ‘You kill only women; you
cannot kill men. You must prove that you kill men.’ So then the soldiers
when they killed us” (here he stopped and hesitated, and then pointing to the
private parts of my bulldog—it was lying asleep at my feet), he said: “then
they cut off those things and took them to the white men, who said: ‘It is
true, you have killed men.’ ”
Q. “You mean to tell me that any white man ordered your bodies to be
mutilated like that, and those parts of you carried to him?”
P P, O O, and all (shouting): “Yes! many white men. D E did it.”
Q. “You say this is true? Were many of you so treated after being shot?”
All (shouting out): “Nkoto! Nkoto!” (Very many! Very many!)
There was no doubt that these people were not inventing. Their
vehemence, their flashing eyes, their excitement, was not simulated.
Doubtless they exaggerated the numbers, but they were clearly telling what
they knew and loathed. I was told that they often became so furious at the
recollection of what had been done to them that they lost control over
themselves. One of the men before me was getting into this state now.
I asked whether L* tribes were still running from their country, or
whether they now stayed at home and worked voluntarily.
N N answered: “They cannot run away now—not easily; there are
sentries in the country there between the Lake and this; besides, there are
few people left.”
P P said: “We heard that letters came to the white men to say that the
people were to be well treated. We heard that these letters had been sent by
the big white men in ‘Mputu’ (Europe); but our white men tore up these
letters, laughing, saying: ‘We are the “basango” and “banyanga” (fathers and
mothers, i.e., elders). Those who write to us are only “bana” (children).’
Since we left our homes the white men have asked us to go home again. We
have heard that they want us to go back, but we will not go. We are not
warriors, and do not want to fight. We only want to live in peace with our
wives and children, and so we stay here among the K*, who are kind to us,
and will not return to our homes.”
Q. “Would you not like to go back to your homes? Would you not, in
your hearts, all wish to return?”
A. (By many.) “We loved our country, but we will not trust ourselves to
go back.”
P P: “Go, you white men, with the steamer to I*, and see what we have
told you is true. Perhaps if other white men, who do not hate us, go there,
Bula Matadi may stop from hating us, and we may be able to go home
again.”
I asked to be pointed out any refugees from other tribes, if there were
such, and they brought forward a lad who was a X**, and a man of the Z**.
These two, answering me, said there were many with them from their tribes
who had fled from their country.

Went on about fifteen minutes to another L* group of houses in the midst


of the K* town. Found here mostly W**, an old Chief sitting in the open
village Council-house with a Z** man and two lads. An old woman soon
came and joined, and another man. The woman began talking with much
earnestness. She said the Government had worked them so hard they had
had no time to tend their fields and gardens, and they had starved to death.
Her children had died; her sons had been killed. The two men, as she spoke,
muttered murmurs of assent.
The old Chief said: “We used to hunt elephants long ago, there were
plenty in our forests, and we got much meat; but Bula Matadi killed the
elephant hunters because they could not get rubber, and so we starved. We
were sent out to get rubber, and when we came back with little rubber we
were shot.”
Q. “Who shot you?”
A. “The white men ... sent their soldiers out to kill us.”
Q. “How do you know it was the white man who sent the soldiers? It
might be only these savage soldiers themselves.”
A. “No, no. Sometimes we brought rubber into the white man’s stations.
We took rubber to D E’s station, E E*, and to F F* and to ...’s station. When
it was not enough rubber the white man would put some of us in lines, one
behind the other, and would shoot through all our bodies. Sometimes he
would shoot us like that with his own hand; sometimes his soldiers would do
it.”
Q. “You mean to say you were killed in the Government posts themselves
by the Government white men themselves, or under their eyes?”
A. (Emphatically.) “We were killed in the stations of the white men
themselves. We were killed by the white man himself. We were shot before
his eyes.”
The names D E, B C, and L M, were names I heard repeatedly uttered.
The Z** man said he, too, had fled; now he lived at peace with the K*.
The abnormal refugee population in this one K* town must equal the
actual K* population itself. On every hand one finds these refugees. They
seem, too, to pass busier lives than their K* hosts, for during all the hot
hours of the afternoon, wherever I walked through the town—and I went all
through N* until the sun set—I found L* weavers, or iron and brass
workers, at work.
Slept at M M’s house. Many people coming to talk to us after dark.
Left N* about 8 to return to the Congo bank. On the way back left the
main path and struck into one of the side towns, a village called A A*. This
lies only some 4 or 5 miles from the river. Found here thirty-two L* houses
with forty-three K*, so that the influx of fugitives here is almost equal to the
original population. Saw many L*. All were frightened, and they and the K*
were evidently so ill at ease that I did not care to pause. Spoke to one or two
men only as we walked through the town. The L* drew away from us, but
on looking back saw many heads popped out of doors of the houses we had
passed.
Got back to steamer about noon.

Heard that L* came sometimes to M* from I*. I am now 100 miles


(about) up-river from N*. Went into one of the M* country farm towns
called B B*. Found on entering plantation two huts with five men and one
woman, who I at once recognized by their head-dress as L*, like those at
N*. The chief speaker, a young man named ... who lives at B B*. He seems
about 22 or 23, and speaks with an air of frankness. He says: “The L* here
and others who come to M*, come from a place C C*. It is connected with
the lake by a stream. His own town in the district of C C* is D D*. C C* is a
big district and had many people. They now bring the Government india-
rubber, kwanga, and fowls, and work on broad paths connecting each
village. His own village has to take 300 baskets of india-rubber. They get
one piece of cotton cloth, called locally sanza, and no more.” (Note.—This
cannot be true. He is doubtless exaggerating.) Four other men with him were
wearing the rough palm-fibre cloth of the country looms, and they pointed to
this as proof that they got no cloth for their labours. K K continuing said:
“We were then killed for not bringing in enough rubber.”
Q. “You say you were killed for not bringing in rubber. Were you ever
mutilated as proof that the soldiers had killed you?”
A. “When we were killed the white man was there himself. No proof was
needed. Men and women were put in a line with a palm tree and were shot.”
Here he took three of the four men sitting down and put them one in line
behind the other, and said: “The white men used to put us like that and shoot
all with one cartridge. That was often done, and worse things.”
Q. “But how, if you now have to work so hard, are you yourselves able to
come here to M* to see your friends?”
A. “We came away without the sentries or soldiers knowing, but when we
get home we may have trouble.”
Q. “Do you know the L* who are now at N*?” (Here I gave the names of
N N, O O, and P P.)
A. “Yes; many L* fled to that country. N N we know ran away on account
of the things done to them by the Government white men. The K* and L*
have always been friends. That is why the L* fled to them for refuge.”
Q. “Are there sentries or soldiers in your villages now?”
A. “In the chief villages there are always four soldiers with rifles. When
natives go out into the forest to collect rubber they would leave one of their
number behind to stay and protect the women. Sometimes the soldiers
finding him thus refused to believe what he said, and killed him for shirking
his work. This often happens.”
Asked how far it was from M* to their country they say three days’
journey, and then about two days more on to I* by water, or three if by land.
They begged us to go to their country, they said: “We will show you the
road, we will take you there, and you will see how things are, and that our
country has been spoiled, and we are speaking the truth.”
Left them here and returned to the river bank.

The foregoing entries made at the time in my note-book seemed to me, if


not false, greatly exaggerated, although the statements were made with
every air of conviction and sincerity. I did not again meet with any more L*
refugees, for on my return to G* I stayed only a few hours. A few days
afterwards, while I was at Stanley Pool, I received further evidence in a
letter of which the following is an extract:—

“I was sorry not to see you as you passed down, and so missed the
opportunity of conveying to you personally a lot of evidence as to the
terrible maladministration practised in the past in the district. I saw the
official at the post of E E*. He is the successor of the infamous wretch D E,
of whom you heard so much yourself from the refugees at N*. This D E was
in this district in ..., ..., and ..., and he it was that depopulated the country.
His successor, M N, is very vehement in his denunciations of him, and
declares that he will leave nothing undone that he can do to bring him to
justice. He is now stationed at G G*, near our station at H H*. Of M N I
have nothing to say but praise. In a very difficult position he has done
wonderfully. The people are beginning to show themselves and gathering
about the many posts under his charge. M N told me that when he took over
the station at E E* from D E he visited the prison, and almost fainted, so
horrible was the condition of the place and the poor wretches in it. He told
me of many things he had heard of from the soldiers. Of D E shooting with
his own hand man after man who had come with an insufficient quantity of
rubber. Of his putting several one behind the other and shooting them all
with one cartridge. Those who accompanied me, also heard from the soldiers
many frightful stories and abundant confirmation of what was told us at N*
about the taking to D E of the organs of the men slain by the sentries of the
various posts. I saw a letter from the present officer at F F* to M N, in which
he upbraids him for not using more vigorous means, telling him to talk less
and shoot more, and reprimanding him for not killing more than one in a
district under his care where there was a little trouble. M N is due in
Belgium in about three months, and says he will land one day and begin
denouncing his predecessor the next. I received many favours from him, and
should be sorry to injure him in any way.... He has already accepted a
position in one of the Companies, being unable to continue longer in the
service of the State. I have never seen in all the different parts of the State
which I have visited a neater station, or a district more under control than
that over which this M N presides. He is the M N the people of N* told us
of, who they said was kind.
“If I can give you any more information, or if there are any questions you
would like to put to me, I shall be glad to serve you, and through you these
persecuted people.”
From a separate communication, I extract the following paragraphs:—
“...I heard of some half-dozen L* who were anxious to visit their old
home, and would be willing to go with me; so, after procuring some
necessary articles in the shape of provisions and barter, I started from our
post at N*. It was the end of the dry season, and many of the water-courses
were quite dry, and during some days we even found the lack of water
somewhat trying. The first two days’ travelling was through alternating
forest and grass plain, our guides, as far as possible, avoiding the villages....
Getting fresh guides from a little village, we got into a region almost entirely
forested, and later descended into a gloomy valley still dripping from the
rain. According to our guides we should soon be through this, but it was not
until the afternoon of the second day after entering that we once more
emerged from the gloom. Several times we lost the track, and I had little
inclination to blame the guides, for several times the undergrowth and a
species of thorn palm were trodden down in all directions by the elephants.
It would seem to be a favourite hunting ground of theirs, and once we got
very close to a large herd who went off at a furious pace, smashing down the
small trees, trumpeting, and making altogether a most terrifying noise. The
second night in this forest we came across, when looking for the track, a
little village of runaways from the rubber district. When assured of our
friendliness they took us in and gave us what shelter they could. During the
night another tornado swept the country and blew down a rotten tree, some
branches of which fell in amongst my tent and the little huts in which some
of the boys were sleeping. It was another most narrow escape.
“Early the next day we were conducted by one of the men of this village
to the right road, and very soon found ourselves travelling along a track
which had evidently been, at only a recent date, opened up by a number of
natives. ‘What was it?’ ‘Oh! it is the road along which we used to carry
rubber to the white men.’ ‘But why used to?’ ‘Oh, all the people have either
run away, or have been killed or died of starvation, and so there is no one to
get rubber any longer.’
“That day we made a very long march, being nearly nine and a-half hours
walking, and passing through several other large depopulated districts. On
all sides were signs of a very recent large population, but all was as quiet as
death, and buffaloes roamed at will amongst the still growing manioc and
bananas. It was a sad day, and when, as the sun was setting, we came upon a
large State post we were plunged into still greater grief. True, there was a
comfortable house at our service, and houses for all the party; but we had
not been long there before we found that we had reached the centre of what
was once a very thickly populated region, known as C C*, from which many
refugees in the neighbourhood of G* had come. It was here a white man,
known by the name of D E, lived.... He came to the district, and, after seven
months of diabolical work, left it a waste. Some of the stories current about
him are not fit to record here, but the native evidence is so consistent and so
universal that it is difficult to disbelieve that murder and rapine on a large
scale were carried on here. His successor, a man of a different nature, and
much liked by the people, after more than two and a-half years has
succeeded in winning back to the side of the State post a few natives, and
there I saw them in their wretched little huts, hardly able to call their lives
their own in the presence of the new white man (myself), whose coming
among them had set them all a-wondering. From this there was no fear of
losing the track. For many miles it was a broad road, from 6 to 10 feet in
width, and wherever there was a possibility of water settling logs were laid
down. Some of these viaducts were miles in length, and must have entailed
immense labour; whilst rejoicing in the great facility with which we could
continue our journey, we could not help picturing the many cruel scenes
which, in all probability, were a constant accompaniment to the laying of
these huge logs. I wish to emphasize as much as possible the desolation and
emptiness of the country we passed through. That it was only very recently a
well-populated country, and, as things go out here, rather more densely than
usual, was very evident. After a few hours we came to a State rubber post. In
nearly every instance these posts are most imposing, some of them giving
rise to the supposition that several white men were residing in them. But in
only one did we find a white man—the successor of D E. At one place I saw
lying about in the grass surrounding the post, which is built on the site of
several very large towns, human bones, skulls, and, in some places,
complete skeletons. On inquiring the reason for this unusual sight: ‘Oh!’
said my informant, ‘When the bambote (soldiers) were sent to make us cut
rubber there were so many killed we got tired of burying, and sometimes
when we wanted to bury we were not allowed to.’
“ ‘But why did they kill you so?’
“ ‘Oh! sometimes we were ordered to go, and the sentry would find us
preparing food to eat while in the forest, and he would shoot two or three to
hurry us along. Sometimes we would try and do a little work on our
plantations, so that when the harvest time came we should have something
to eat, and the sentry would shoot some of us to teach us that our business
was not to plant but to get rubber. Sometimes we were driven off to live for
a fortnight in the forest without any food and without anything to make a
fire with, and many died of cold and hunger. Sometimes the quantity
brought was not sufficient, and then several would be killed to frighten us to
bring more. Some tried to run away, and died of hunger and privation in the
forest in trying to avoid the State posts.’
“ ‘But,’ said I, ‘if the sentries killed you like that, what was the use? You
could not bring more rubber when there were fewer people.’
“ ‘Oh! as to that, we do not understand it. These are the facts.’
“And looking around on the scene of desolation, on the untended farms
and neglected palms, one could not but believe that in the main the story
was true. From State sentries came confirmation and particulars even more
horrifying, and the evidence of a white man as to the state of the country—
the unspeakable condition of the prisons at the State posts—all combined to
convince me over and over again that, during the last seven years, this
‘domaine privé’ of King Leopold has been a veritable ‘hell on earth.’
“The present régime seems to be more tolerable. A small payment is
made for the rubber now brought in. A little salt—say a pennyworth—for 2
kilogrammes of rubber, worth in Europe from 6 to 8 fr. The collection is still
compulsory, but, compared with what has gone before, the natives consider
themselves fairly treated. There is a coming together of families and
communities and the re-establishment of villages; but oh! in what sadly
diminished numbers, and with what terrible gaps in the families.... Near a
large State post we saw the only large and apparently normal village we
came across in all the three weeks we spent in the district. One was able to
form here some estimate of what the population was before the advent of the
white man and the search for rubber....”

It will be observed that the devastated region whence had come the
refugees I saw at N*, comprises a part of the “Domaine de la Couronne.”
Inclosure 2 in No. 3.
(See p. 29.)
(A.)
The Rev. J. Whitehead to Governor-General of Congo State.
Dear Sir,
Baptist Missionary Society, Lukolela, July 28, 1903.
I HAVE the honour to acknowledge the receipt of the Circular and the
List of Questions respecting the sleep sickness sent through the Rev. J. L.
Forfeitt.
I hasten to do my best in reply, for the matter is of paramount importance,
and I trust that if I may seem to trespass beyond my limits in stating my
opinions in reference to this awful sickness and matters kindred thereto, my
zeal may be interpreted as arising from excessive sorrow and sympathy for a
disappearing people. I believe I shall be discharging my duty to the State
and His Majesty King Leopold II, whose desire for the facts in the interests
of humanity have long been published, if I endeavour to express myself as
clearly as I can regarding the necessities of the natives of Lukolela.
The population of the villages of Lukolela in January 1891 must have
been not less than 6,000 people, but when I counted the whole population in
Lukolela at the end of December 1896 I found it to be only 719, and I
estimated from the decrease, as far as we could count up the number of
known deaths during the year, that at the same rate of decrease in ten years
the people would be reduced to about 400, but judge of my heartache when
on counting them all again on Friday and Saturday last to find only a
population of 352 people, and the death-rate rapidly increasing. I note also a
decrease very appallingly apparent in the inland districts during the same
number of years; three districts are well-nigh swept out (these are near to the
river), and others are clearly diminished; so that if something is not soon
done to give the people heart and remove their fear and trembling
(conditions which generate fruitfully morbid conditions and proneness to
attacks of disease), doubtless the whole place will be very soon denuded of
its population. The pressure under which they live at present is crushing
them; the food which they sadly need themselves very often must, under
penalty, be carried to the State post, also grass, cane string, baskets for the
“caoutchouc” (the last three items do not appear to be paid for); the
“caoutchouc” must be brought in from the inland districts; their Chiefs are
being weakened in their prestige and physique through imprisonment, which
is often cruel, and thus weakened in their authority over their own people,
they are put into chains for the shortage of manioc bread and “caoutchouc.”
In the riverine part of Lukolela we have done our very best as non-
official members of the State to cope with disease in every way possible to
us; but so far the officials of the State have never attempted even the feeblest
effort to assist the natives of Lukolela to recover themselves or guard
themselves in any way from disease. In times of small-pox, when no time
can be lost in the interests of the community, I have, perhaps, gone
sometimes beyond my rights as a private citizen in dealing with it. But there
has always been the greatest difficulty in getting food for them (the patients)
and nurses for them, even when the people were not compelled to take their
food supply to the State post, but when food supplies and labour are
compressed into one channel all voluntary philanthropy is paralyzed. It is
quite in vain for us to teach these poor people the need of plenty of good
food, for we appear to them as those who mock; they point to the food
which must be taken to the post. A weekly tax of 900 brass rods’ worth of
manioc bread from 160 women, half of whom are not capable of much hard
and continuous work, does not leave much margin for them to listen to
teaching concerning personal attention in matters of food. At present they
are compelled to supply a number of workmen, and some of these are
retained after their terms are completed against their will; the villages need
the presence of their men, there are at present but eighty-two in the villages
of Lukolela, and I can see the shadow of death over nearly twenty of them.
[21]
The inland people and their Chiefs tremble when they must go down to
the river, so much has been done latterly to shake their confidence, and this
fear is not strengthening them physically, but undermining their
constitutions, such as they are. They hate the compulsory “caoutchouc”
business, and they naturally do their best to get away from it. If something is
not quickly done to give these timid and disheartened people contentment
and their home life assured to them, sickness will speedily remove many,
and those who remain will look upon the white man, of whatever nation or
position, as their natural enemy (it is not far from that now). Some have
already sworn to die, be killed, or anything else rather than be forced to
bring in “caoutchouc,” which spells imprisonment and subsequent death to
them; what they hear as having been done they quite understand can be done
to them, so they conclude they may as well die first as last. The State has
fought with them twice already, if not more; but it is useless, they will not
submit. A cave of Adullam is a thing not always easily reckoned with.
May I be permitted to seize the present opportunity of respectfully
pleading on behalf of this people that their rights be respected, and that the
attention as of a father to his children be sympathetically shown them? May
I also be permitted to place before you a few suggestions which have been
impelled into my mind face to face with this dying people of what is their
need while medical inquiry goes forward, please God, to master this terrible
scourge? I suggest the following as immediately needful for the riverine
people:—
1. That the present small population of Lukolela be requested to vacate
the present site of their dwellings, and form a community on the somewhat
higher ground at present used for gardens, the soil of which has been
impoverished by years of manioc growing. This is known by the name
Ntomba; and that they be requested to clear the undergrowth on the beach,
the sites of their present dwellings, and plant bananas, &c.
2. That no one known to have sleep-sickness be permitted to dwell on the
new site; but all be removed to a site lower down the river; and that it shall
be the duty of the people to supply their sick with the necessary food and
caretakers. The islands are unsuitable, being uninhabitable for a large part of
the year.
3. That they be compelled to bury their dead at a considerable distance
from the dwellings, and to bury them in graves at least a fathom deep, and
not as at present in shallow graves in close proximity to the houses.
4. That they be encouraged to build higher houses with more apertures
for the ingress of sunshine and air in the daytime, and with floors
considerably raised above the outside ground.
5. That a strong endeavour be made to get them to provide better latrine
arrangements.
6. That they be encouraged to give up eating and drinking together from
the same dish or vessel in common.
7. That the men be encouraged to follow their old practices of hunting,
fishing, blacksmithing, &c., and with the women care for their gardens and
homes, and that they be given every protection in these duties and in the
holding of their property against the State soldiers and workmen and
everybody else that wants to interfere with their rights.
8. All the foregoing they will not be able to do unless the present
compulsory method of acquiring their labour and their food by the State is
exchanged for a voluntary one.
9. That the Chiefs or present chief representatives of the deceased Chiefs
among whom the land was divided before the State came into existence (I
believe about three will be found at Lukolela itself) be recognized as the
executive of these matters, and that they be requested to devote their levies
(restored as of old) made on the produce, &c., of their lands to the
betterment of their towns and district, by making roads through their lands,
&c.
10. To appoint sentries to carry out either the above or any other
beneficent rules in any of the villages would be to endeavour to mend the
present deplorable condition with an evil a hundred-fold worse.
All the above suggestions adjusted to suit the locality are equally
applicable to the inland districts.
In answering the list of questions I would say:—
1. Sleep-sickness is sadly only too well known at Lukolela. It is prevalent
in the whole of the riverine and inland districts. In the inland districts I am
not yet able to say whether it is more prevalent than in the riverine one; that
can only be ascertained by a more prolonged residence there than as yet I
have had opportunity to make. In the riverine district I estimate that quite
half of the deaths are from sleep-sickness. The cases do not occur in batches
like cases of small-pox and measles do; there are too many in a given place
unaffected at one time. It will, however, gradually sweep away whole
families. The common notion among the natives is that the sickness came
from down-river; and it was prevalent, though not to such an extent as now,
as far back as the oldest people I have met can remember. Before our
Mission was founded here a suspected case would be thrown into the river;
but inland I do not think there is any evidence to show that they did
otherwise than to-day—nurse their sick perfectly, heedless of the contagion
in respect of them (the nurses) or their friends, and, as they do on the beach,
bury their dead close to their houses, and in some cases live on the top of the
graves.
2. From my own observation (since January 1891) the sickness is
endemic; in the riverine villages the death-rate slowly increased until 1894,
when the people quite lost heart and felt their homes were no longer secure
to them, and then hunger, improper food, fear, and homelessness appeared to
increase the death-rate from sleep-sickness and other causes most
appallingly, and the rate has still further increased, especially during the last
two years. The fewer the population becomes the proportionate rate of death
increases most fearfully.
3. The district of Lukolela may be described as follows: The beach line is
wooded, broken by one or two creeks, one of which winds for a
considerable distance inland to a district which can be reached overland by a
journey of at least three days at the shortest. There is more or less of low-
lying land connected with the creeks. The 6 miles below the Mission station
is lower than the 8 miles above. The highest point of our land is about 19
metres above high-water level, and possibly there is a further rise of 3
metres or so further up stream. The ground which I suggest the people be
removed to may be on an average about 12 to 15 metres above high-water
level. This ridge of river bank shelves down into low-wooded land and grass
plains which are flooded at high water, though for the most part dry at the
lowest ebb; then behind these rise small plateaus separated by low valleys of
wooded and grassy land. From the pools and streams of this low ground the
people get most of their fish; even when the river is at medium height a
journey between the various plateaus where the villages and farms are found
requires about half the time to be spent in wading, sometimes breast deep.
4. A large proportion of the population is comprised of slaves, mostly
from the tributaries of the Equator district, some from the Mobsi, Likuba,
and Likwala peoples on the north bank, some from Ngombe below Irebu,
some from as far as the district of Lake Léopold II and other places. All the
tribes represented seem equally affected, and neither slave nor freeman
seems to have preferential treatment.
5. To an ordinary observer the men, women, and children appear to be
affected alike. It is not easy to always differentiate the sickness from other
maladies, for often it may be that the malady gives rise to various
complications; these complications are extremely intractable if sleep-
sickness be present. When a man in the prime of life has his prestige and
spirit broken through fear and punishment he loses interest in his home,
refuses to take food and drink; a sleep-sickness patient will do the same.
With the women in all cases we have known there is also present
amenorrhœa; sometimes treatment for this has restored the patient in this
respect for a time, but there has in all cases we have known of this sort been
a relapse; so whether the patient died of one or the other would be difficult
to say.
6. The well-fed do not seem to fall before the scourge so rapidly as the
ill-fed. The progress of the disease seems to us considerably slower as a rule
with those who take care of their food and habits, but it attacks even the
most scrupulously attentive to these matters.
There is a very bad practice amongst them: they will go sometimes days
without eating, although they may have manioc and plantain, and other
foods from the soil at hand, simply because they have no fish or flesh to eat
with them; sometimes they pinch themselves in food to retain their brass
rods for the purchase of some coveted article. The natives to-day are not so
careful in the preparation of food, and it is more hastily performed; the
manioc is eaten as nearly the raw state as they dare use it. The bitter manioc
is mostly grown, as the yield from it is greater than from any other kind.
Plantains are largely eaten roasted, and boiled, and beaten into a pudding.
Palm-nuts, too, they are very fond of, and the oil forms a good part of the
cooked foods. They use, especially in the absence of fish or flesh, the leaves
of the manioc, which are bruised and boiled; in nearly every case, however,
head-and stomach-ache follow, which pass off in a few days if bowels be
active. Well-peppered food they enjoy, and rotten fish and flesh they do not,
as a rule, despise. Their dried fish, of which a large quantity is eaten, is not
by any means always free from maggots. Elephant meat seems to give them
diarrhœa; dog-headed bats similarly; hippo meat generally produces slight
constipation. I am afraid a good deal of disease is passed from person to
person in the preparation of food. There is a great deal of eating together and
drinking together from one and the same vessel; they dip their hands in the
mess prepared as they sit round the pot, and I cannot say that they are too
careful of the condition of their hands at the time. Clothing is usually scant
except for decoration; hence the colder the weather the less the clothing, the
brighter and warmer the more they carry. Washing is not a very frequent
exercise among the natives. They like, as a rule, teeth kept clean, washing
them every day and after every meal. They like to smear their bodies with
oil and camwood. The hair is left undressed or dressed as the case may be
for weeks at a time without further cleansing. Sleeping is mostly done on
raised constructions of sticks, varying from half a-foot from the ground to
about 3 feet or so. I am afraid that not much in the way of covering is used
while sleeping, a blanket being mostly worn during the day as an article of
fine clothing. Many, especially those in temporary residence, sleep on the
ground floor with only a mat intervening. Jiggers, bugs, mosquitos, and
vermin abound in their houses on the beach, but jiggers are not so plentiful,
and mosquitos very rare inland. The inland people take great care of their
water sources, but on the beach the river water is largely used, and this is of
a dark brown colour; some is taken from the creeks, but it is very impure,
abounding with decayed vegetation and clay, and some from springs, such
as they are, and these are only surface drainings over the clayey subsoil. The
sweepings of their huts and refuse from their food is not thrown far away,
sometimes even being quite close up against one of the walls of the hut. In
the daytime they relieve themselves in the nearest sheltered spot without
further discrimination, and these places, in the present uncleared character of
their surroundings, are very close at hand; in the night time they are not so
particular, but will even relieve themselves in the open, and on the paths trod
by every one. The common belief is that the disease is communicated by
means of the secretions, and yet, strange to say, the natives take scarcely any
precautions.
7. All the cases we have known have been fatal. We have thought
sometimes we have done good with iodide of potassium and cod-liver oil,
but if it did any good at all it was only very temporary. We judge from our
observations that from the first symptoms which appear to be mental ones,
the best cared for cases last for from one to three years. Others in which
food is soon refused and neglect is suffered may speedily terminate in a few
months, or even weeks, from the first certain indications. The first
symptoms seem to be mental, the balance of thought fails at intervals, then
come the physical signs of pain in the lower part of the back; often thought
here to be piles, and they seek the usual remedies for this; later the pain

You might also like