100% found this document useful (3 votes)
32 views51 pages

(Ebook PDF) Java How To Program, Late Objects Global Edition 11th Edition Download

The document provides links to various eBooks related to Java and C++ programming, including titles such as 'Java How to Program, Late Objects' and 'C++ How to Program: An Objects-Natural Approach'. It also includes trademark information and a detailed table of contents for the Java programming book, covering topics from basic concepts to advanced programming techniques. The document encourages readers to download the eBooks from the provided links.

Uploaded by

oprfflwf940
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
32 views51 pages

(Ebook PDF) Java How To Program, Late Objects Global Edition 11th Edition Download

The document provides links to various eBooks related to Java and C++ programming, including titles such as 'Java How to Program, Late Objects' and 'C++ How to Program: An Objects-Natural Approach'. It also includes trademark information and a detailed table of contents for the Java programming book, covering topics from basic concepts to advanced programming techniques. The document encourages readers to download the eBooks from the provided links.

Uploaded by

oprfflwf940
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

(eBook PDF) Java How to Program, Late Objects

Global Edition 11th Edition download

https://ebookluna.com/product/ebook-pdf-java-how-to-program-late-
objects-global-edition-11th-edition/

Download full version ebook from https://ebookluna.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebookluna.com
to discover even more!

(eBook PDF) Java How To Program (Early Objects) 10th

https://ebookluna.com/product/ebook-pdf-java-how-to-program-early-
objects-10th/

(eBook PDF) Java How to Program, Early Objects 11th Edition by Paul J.
Deitel

https://ebookluna.com/product/ebook-pdf-java-how-to-program-early-
objects-11th-edition-by-paul-j-deitel/

(eBook PDF) Java Concepts: Late Objects, 3rd Edition

https://ebookluna.com/product/ebook-pdf-java-concepts-late-objects-3rd-
edition/

(eBook PDF) Big Java Late Objects 2nd Edition

https://ebookluna.com/product/ebook-pdf-big-java-late-objects-2nd-edition/
C++ How to Program: An Objects-Natural Approach, 11e 11th Edition Paul
Deitel - eBook PDF

https://ebookluna.com/download/c-how-to-program-an-objects-natural-
approach-11e-ebook-pdf/

C++ How to Program Early Objects Version 9th Edition (eBook PDF)

https://ebookluna.com/product/c-how-to-program-early-objects-version-9th-
edition-ebook-pdf/

C How to Program, 9th Global Edition Deitel Paul - eBook PDF

https://ebookluna.com/download/c-how-to-program-9th-global-edition-ebook-
pdf/

(eBook PDF) Big C++: Late Objects 3rd Edition

https://ebookluna.com/product/ebook-pdf-big-c-late-objects-3rd-edition/

(eBook PDF) Brief C++: Late Objects, 3rd Edition

https://ebookluna.com/product/ebook-pdf-brief-c-late-objects-3rd-edition/
Trademarks
DEITEL and the double-thumbs-up bug are registered trademarks of Deitel and Associates, Inc.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks
of their respective owners.
Microsoft and/or its respective suppliers make no representations about the suitability of the information
contained in the documents and related graphics published as part of the services for any purpose. All
such documents and related graphics are provided “as is” without warranty of any kind. Microsoft and/
or its respective suppliers hereby disclaim all warranties and conditions with regard to this information,
including all warranties and conditions of merchantability, whether express, implied or statutory, fitness
for a particular purpose, title and non-infringement. In no event shall Microsoft and/or its respective sup-
pliers be liable for any special, indirect or consequential damages or any damages whatsoever resulting
from loss of use, data or profits, whether in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of information available from the services.
The documents and related graphics contained herein could include technical inaccuracies or typograph-
ical errors. Changes are periodically added to the information herein. Microsoft and/or its respective sup-
pliers may make improvements and/or changes in the product(s) and/or the program(s) described herein
at any time. Partial screen shots may be viewed in full within the software version specified.
Microsoft® and Windows® are registered trademarks of the Microsoft Corporation in the U.S.A. and
other countries. Screen shots and icons reprinted with permission from the Microsoft Corporation. This
book is not sponsored or endorsed by or affiliated with the Microsoft Corporation.
UNIX is a registered trademark of The Open Group.
Apache is a trademark of The Apache Software Foundation.
CSS and XML are registered trademarks of the World Wide Web Consortium.
Firefox is a registered trademark of the Mozilla Foundation.
Google is a trademark of Google, Inc.
Mac and macOS are trademarks of Apple Inc., registered in the U.S. and other countries.
Linux is a registered trademark of Linus Torvalds. All trademarks are property of their respective owners.
Throughout this book, trademarks are used. Rather than put a trademark symbol in every occurrence of
a trademarked name, we state that we are using the names in an editorial fashion only and to the benefit
of the trademark owner, with no intention of infringement of the trademark.
Contents
The online chapters and appendices listed at the end of this Table of Contents are located
on the book’s Companion Website (http://www.pearsonglobaleditions.com)—see
the inside front cover of your book for details.

Foreword 25

Preface 27

Before You Begin 47

1 Introduction to Computers, the Internet and Java 53


1.1 Introduction 54
1.2 Hardware and Software 56
1.2.1 Moore’s Law 56
1.2.2 Computer Organization 57
1.3 Data Hierarchy 59
1.4 Machine Languages, Assembly Languages and High-Level Languages 61
1.5 Basic Introduction to Object Terminology 62
1.5.1 Automobile as an Object 63
1.5.2 Methods and Classes 63
1.5.3 Instantiation 63
1.5.4 Reuse 63
1.5.5 Messages and Method Calls 64
1.5.6 Attributes and Instance Variables 64
1.5.7 Encapsulation and Information Hiding 64
1.5.8 Inheritance 64
1.5.9 Interfaces 65
1.5.10 Object-Oriented Analysis and Design (OOAD) 65
1.5.11 The UML (Unified Modeling Language) 65
1.6 Operating Systems 66
1.6.1 Windows—A Proprietary Operating System 66
1.6.2 Linux—An Open-Source Operating System 66
1.6.3 Apple’s macOS and Apple’s iOS for iPhone®, iPad® and
iPod Touch® Devices 67
1.6.4 Google’s Android 67
8 Contents

1.7 Programming Languages 68


1.8 Java 70
1.9 A Typical Java Development Environment 71
1.10 Test-Driving a Java Application 74
1.11 Internet and World Wide Web 78
1.11.1 Internet: A Network of Networks 79
1.11.2 World Wide Web: Making the Internet User-Friendly 79
1.11.3 Web Services and Mashups 79
1.11.4 Internet of Things 80
1.12 Software Technologies 81
1.13 Getting Your Questions Answered 83

2 Introduction to Java Applications; Input/Output


and Operators 87
2.1 Introduction 88
2.2 Your First Program in Java: Printing a Line of Text 88
2.2.1 Compiling the Application 92
2.2.2 Executing the Application 93
2.3 Modifying Your First Java Program 94
2.4 Displaying Text with printf 96
2.5 Another Application: Adding Integers 97
2.5.1 import Declarations 98
2.5.2 Declaring and Creating a Scanner to Obtain User Input
from the Keyboard 98
2.5.3 Prompting the User for Input 99
2.5.4 Declaring a Variable to Store an Integer and Obtaining an
Integer from the Keyboard 99
2.5.5 Obtaining a Second Integer 100
2.5.6 Using Variables in a Calculation 100
2.5.7 Displaying the Calculation Result 100
2.5.8 Java API Documentation 101
2.5.9 Declaring and Initializing Variables in Separate Statements 101
2.6 Memory Concepts 101
2.7 Arithmetic 102
2.8 Decision Making: Equality and Relational Operators 106
2.9 Wrap-Up 109

3 Control Statements: Part 1; Assignment,


++ and -- Operators 120
3.1 Introduction 121
3.2 Algorithms 121
3.3 Pseudocode 122
3.4 Control Structures 122
3.4.1 Sequence Structure in Java 123
Contents 9

3.4.2 Selection Statements in Java 124


3.4.3 Iteration Statements in Java 124
3.4.4 Summary of Control Statements in Java 124
3.5 if Single-Selection Statement 125
3.6 if…else Double-Selection Statement 126
3.6.1 Nested if…else Statements 127
3.6.2 Dangling-else Problem 128
3.6.3 Blocks 128
3.6.4 Conditional Operator (?:) 129
3.7 while Iteration Statement 129
3.8 Formulating Algorithms: Counter-Controlled Iteration 131
3.9 Formulating Algorithms: Sentinel-Controlled Iteration 135
3.10 Formulating Algorithms: Nested Control Statements 142
3.11 Compound Assignment Operators 146
3.12 Increment and Decrement Operators 147
3.13 Primitive Types 150
3.14 Wrap-Up 150

4 Control Statements: Part 2; Logical Operators 164


4.1 Introduction 165
4.2 Essentials of Counter-Controlled Iteration 165
4.3 for Iteration Statement 166
4.4 Examples Using the for Statement 170
4.4.1 Application: Summing the Even Integers from 2 to 20 171
4.4.2 Application: Compound-Interest Calculations 172
4.5 do…while Iteration Statement 175
4.6 switch Multiple-Selection Statement 176
4.7 break and continue Statements 182
4.7.1 break Statement 182
4.7.2 continue Statement 182
4.8 Logical Operators 183
4.8.1 Conditional AND (&&) Operator 184
4.8.2 Conditional OR (||) Operator 184
4.8.3 Short-Circuit Evaluation of Complex Conditions 185
4.8.4 Boolean Logical AND (&) and Boolean Logical Inclusive OR (|)
Operators 185
4.8.5 Boolean Logical Exclusive OR (^) 186
4.8.6 Logical Negation (!) Operator 186
4.8.7 Logical Operators Example 187
4.9 Structured-Programming Summary 189
4.10 Wrap-Up 194

5 Methods 204
5.1 Introduction 205
10 Contents

5.2 Program Units in Java 205


5.3 static Methods, static Variables and Class Math 207
5.4 Declaring Methods 209
5.5 Notes on Declaring and Using Methods 213
5.6 Method-Call Stack and Activation Records 214
5.6.1 Method-Call Stack 214
5.6.2 Stack Frames 214
5.6.3 Local Variables and Stack Frames 215
5.6.4 Stack Overflow 215
5.7 Argument Promotion and Casting 215
5.8 Java API Packages 216
5.9 Case Study: Secure Random-Number Generation 218
5.10 Case Study: A Game of Chance; Introducing enums 223
5.11 Scope of Declarations 227
5.12 Method Overloading 230
5.12.1 Declaring Overloaded Methods 230
5.12.2 Distinguishing Between Overloaded Methods 231
5.12.3 Return Types of Overloaded Methods 231
5.13 Wrap-Up 232

6 Arrays and ArrayLists 245


6.1 Introduction 246
6.2 Primitive Types vs. Reference Types 247
6.3 Arrays 247
6.4 Declaring and Creating Arrays 249
6.5 Examples Using Arrays 250
6.5.1 Creating and Initializing an Array 250
6.5.2 Using an Array Initializer 251
6.5.3 Calculating the Values to Store in an Array 252
6.5.4 Summing the Elements of an Array 253
6.5.5 Using Bar Charts to Display Array Data Graphically 254
6.5.6 Using the Elements of an Array as Counters 256
6.5.7 Using Arrays to Analyze Survey Results 257
6.6 Exception Handling: Processing the Incorrect Response 259
6.6.1 The try Statement 259
6.6.2 Executing the catch Block 259
6.6.3 toString Method of the Exception Parameter 260
6.7 Enhanced for Statement 260
6.8 Passing Arrays to Methods 261
6.9 Pass-By-Value vs. Pass-By-Reference 264
6.10 Multidimensional Arrays 264
6.10.1 Arrays of One-Dimensional Arrays 265
6.10.2 Two-Dimensional Arrays with Rows of Different Lengths 265
6.10.3 Creating Two-Dimensional Arrays with Array-Creation
Expressions 266
Contents 11

6.10.4 Two-Dimensional Array Example: Displaying Element Values 266


6.10.5 Common Multidimensional-Array Manipulations Performed
with for Statements 267
6.11 Variable-Length Argument Lists 268
6.12 Using Command-Line Arguments 269
6.13 Class Arrays 271
6.14 Introduction to Collections and Class ArrayList 274
6.15 Wrap-Up 278

7 Introduction to Classes and Objects 298


7.1 Introduction 299
7.2 Instance Variables, set Methods and get Methods 300
7.2.1 Account Class with an Instance Variable, and set and get Methods 300
7.2.2 AccountTest Class That Creates and Uses an Object of
Class Account 302
7.2.3 Compiling and Executing an App with Multiple Classes 305
7.2.4 Account UML Class Diagram 305
7.2.5 Additional Notes on Class AccountTest 306
7.2.6 Software Engineering with private Instance Variables and
public set and get Methods 307
7.3 Default and Explicit Initialization for Instance Variables 308
7.4 Account Class: Initializing Objects with Constructors 309
7.4.1 Declaring an Account Constructor for Custom Object
Initialization 309
7.4.2 Class AccountTest: Initializing Account Objects When
They’re Created 310
7.5 Account Class with a Balance 312
7.5.1 Account Class with a balance Instance Variable of Type double 312
7.5.2 AccountTest Class to Use Class Account 313
7.6 Case Study: Card Shuffling and Dealing Simulation 316
7.7 Case Study: Class GradeBook Using an Array to Store Grades 320
7.8 Case Study: Class GradeBook Using a Two-Dimensional Array 326
7.9 Wrap-Up 331

8 Classes and Objects: A Deeper Look 339


8.1 Introduction 340
8.2 Time Class Case Study 340
8.3 Controlling Access to Members 345
8.4 Referring to the Current Object’s Members with the this Reference 346
8.5 Time Class Case Study: Overloaded Constructors 348
8.6 Default and No-Argument Constructors 353
8.7 Notes on Set and Get Methods 354
8.8 Composition 355
8.9 enum Types 358
12 Contents

8.10 Garbage Collection 361


8.11 static Class Members 361
8.12 static Import 365
8.13 final Instance Variables 366
8.14 Package Access 367
8.15 Using BigDecimal for Precise Monetary Calculations 368
8.16 (Optional) GUI and Graphics Case Study: Using Objects with Graphics 371
8.17 Wrap-Up 375

9 Object-Oriented Programming: Inheritance 383


9.1 Introduction 384
9.2 Superclasses and Subclasses 385
9.3 protected Members 387
9.4 Relationship Between Superclasses and Subclasses 388
9.4.1 Creating and Using a CommissionEmployee Class 388
9.4.2 Creating and Using a BasePlusCommissionEmployee Class 393
9.4.3 Creating a CommissionEmployee–BasePlusCommissionEmployee
Inheritance Hierarchy 398
9.4.4 CommissionEmployee–BasePlusCommissionEmployee
Inheritance Hierarchy Using protected Instance Variables 401
9.4.5 CommissionEmployee–BasePlusCommissionEmployee Inheritance
Hierarchy Using private Instance Variables 404
9.5 Constructors in Subclasses 408
9.6 Class Object 409
9.7 Designing with Composition vs. Inheritance 410
9.8 Wrap-Up 412

10 Object-Oriented Programming: Polymorphism


and Interfaces 417
10.1 Introduction 418
10.2 Polymorphism Examples 420
10.3 Demonstrating Polymorphic Behavior 421
10.4 Abstract Classes and Methods 423
10.5 Case Study: Payroll System Using Polymorphism 426
10.5.1 Abstract Superclass Employee 427
10.5.2 Concrete Subclass SalariedEmployee 429
10.5.3 Concrete Subclass HourlyEmployee 431
10.5.4 Concrete Subclass CommissionEmployee 432
10.5.5 Indirect Concrete Subclass BasePlusCommissionEmployee 434
10.5.6 Polymorphic Processing, Operator instanceof and Downcasting 435
10.6 Allowed Assignments Between Superclass and Subclass Variables 440
10.7 final Methods and Classes 440
10.8 A Deeper Explanation of Issues with Calling Methods from Constructors 441
10.9 Creating and Using Interfaces 442
10.9.1 Developing a Payable Hierarchy 444
Contents 13

10.9.2 Interface Payable 445


10.9.3 Class Invoice 445
10.9.4 Modifying Class Employee to Implement Interface Payable 447
10.9.5 Using Interface Payable to Process Invoices and Employees
Polymorphically 449
10.9.6 Some Common Interfaces of the Java API 450
10.10 Java SE 8 Interface Enhancements 451
10.10.1 default Interface Methods 451
10.10.2 static Interface Methods 452
10.10.3 Functional Interfaces 452
10.11 Java SE 9 private Interface Methods 453
10.12 private Constructors 453
10.13 Program to an Interface, Not an Implementation 454
10.13.1 Implementation Inheritance Is Best for Small Numbers of
Tightly Coupled Classes 454
10.13.2 Interface Inheritance Is Best for Flexibility 454
10.13.3 Rethinking the Employee Hierarchy 455
10.14 (Optional) GUI and Graphics Case Study: Drawing with Polymorphism 456
10.15 Wrap-Up 458

11 Exception Handling: A Deeper Look 465


11.1 Introduction 466
11.2 Example: Divide by Zero without Exception Handling 467
11.3 Example: Handling ArithmeticExceptions and
InputMismatchExceptions 469
11.4 When to Use Exception Handling 475
11.5 Java Exception Hierarchy 475
11.6 finally Block 479
11.7 Stack Unwinding and Obtaining Information from an Exception 483
11.8 Chained Exceptions 486
11.9 Declaring New Exception Types 488
11.10 Preconditions and Postconditions 489
11.11 Assertions 489
11.12 try-with-Resources: Automatic Resource Deallocation 491
11.13 Wrap-Up 492

12 JavaFX Graphical User Interfaces: Part 1 498


12.1 Introduction 499
12.2 JavaFX Scene Builder 500
12.3 JavaFX App Window Structure 501
12.4 Welcome App—Displaying Text and an Image 502
12.4.1 Opening Scene Builder and Creating the File Welcome.fxml 502
12.4.2 Adding an Image to the Folder Containing Welcome.fxml 503
12.4.3 Creating a VBox Layout Container 503
12.4.4 Configuring the VBox Layout Container 504
12.4.5 Adding and Configuring a Label 504
14 Contents

12.4.6 Adding and Configuring an ImageView 505


12.4.7 Previewing the Welcome GUI 507
12.5 Tip Calculator App—Introduction to Event Handling 507
12.5.1 Test-Driving the Tip Calculator App 508
12.5.2 Technologies Overview 509
12.5.3 Building the App’s GUI 511
12.5.4 TipCalculator Class 518
12.5.5 TipCalculatorController Class 520
12.6 Features Covered in the Other JavaFX Chapters 525
12.7 Wrap-Up 525

13 JavaFX GUI: Part 2 533


13.1 Introduction 534
13.2 Laying Out Nodes in a Scene Graph 534
13.3 Painter App: RadioButtons, Mouse Events and Shapes 536
13.3.1 Technologies Overview 536
13.3.2 Creating the Painter.fxml File 538
13.3.3 Building the GUI 538
13.3.4 Painter Subclass of Application 541
13.3.5 PainterController Class 542
13.4 Color Chooser App: Property Bindings and Property Listeners 546
13.4.1 Technologies Overview 546
13.4.2 Building the GUI 547
13.4.3 ColorChooser Subclass of Application 549
13.4.4 ColorChooserController Class 550
13.5 Cover Viewer App: Data-Driven GUIs with JavaFX Collections 552
13.5.1 Technologies Overview 553
13.5.2 Adding Images to the App’s Folder 553
13.5.3 Building the GUI 553
13.5.4 CoverViewer Subclass of Application 555
13.5.5 CoverViewerController Class 555
13.6 Cover Viewer App: Customizing ListView Cells 557
13.6.1 Technologies Overview 558
13.6.2 Copying the CoverViewer App 558
13.6.3 ImageTextCell Custom Cell Factory Class 559
13.6.4 CoverViewerController Class 560
13.7 Additional JavaFX Capabilities 561
13.8 JavaFX 9: Java SE 9 JavaFX Updates 563
13.9 Wrap-Up 565

14 Strings, Characters and Regular Expressions 574


14.1 Introduction 575
14.2 Fundamentals of Characters and Strings 575
14.3 Class String 576
14.3.1 String Constructors 576
Contents 15

14.3.2 String Methods length, charAt and getChars 577


14.3.3 Comparing Strings 579
14.3.4 Locating Characters and Substrings in Strings 583
14.3.5 Extracting Substrings from Strings 585
14.3.6 Concatenating Strings 586
14.3.7 Miscellaneous String Methods 587
14.3.8 String Method valueOf 588
14.4 Class StringBuilder 589
14.4.1 StringBuilder Constructors 590
14.4.2 StringBuilder Methods length, capacity, setLength and
ensureCapacity 591
14.4.3 StringBuilder Methods charAt, setCharAt, getChars and
reverse 592
14.4.4 StringBuilder append Methods 593
14.4.5 StringBuilder Insertion and Deletion Methods 595
14.5 Class Character 596
14.6 Tokenizing Strings 601
14.7 Regular Expressions, Class Pattern and Class Matcher 602
14.7.1 Replacing Substrings and Splitting Strings 607
14.7.2 Classes Pattern and Matcher 609
14.8 Wrap-Up 611

15 Files, Input/Output Streams, NIO and


XML Serialization 622
15.1 Introduction 623
15.2 Files and Streams 623
15.3 Using NIO Classes and Interfaces to Get File and Directory Information 625
15.4 Sequential Text Files 629
15.4.1 Creating a Sequential Text File 629
15.4.2 Reading Data from a Sequential Text File 632
15.4.3 Case Study: A Credit-Inquiry Program 633
15.4.4 Updating Sequential Files 638
15.5 XML Serialization 638
15.5.1 Creating a Sequential File Using XML Serialization 638
15.5.2 Reading and Deserializing Data from a Sequential File 644
15.6 FileChooser and DirectoryChooser Dialogs 645
15.7 (Optional) Additional java.io Classes 651
15.7.1 Interfaces and Classes for Byte-Based Input and Output 651
15.7.2 Interfaces and Classes for Character-Based Input and Output 653
15.8 Wrap-Up 654

16 Generic Collections 662


16.1 Introduction 663
16.2 Collections Overview 663
16 Contents

16.3 Type-Wrapper Classes 665


16.4 Autoboxing and Auto-Unboxing 665
16.5 Interface Collection and Class Collections 665
16.6 Lists 666
16.6.1 ArrayList and Iterator 667
16.6.2 LinkedList 669
16.7 Collections Methods 674
16.7.1 Method sort 674
16.7.2 Method shuffle 678
16.7.3 Methods reverse, fill, copy, max and min 680
16.7.4 Method binarySearch 682
16.7.5 Methods addAll, frequency and disjoint 683
16.8 Class PriorityQueue and Interface Queue 685
16.9 Sets 686
16.10 Maps 689
16.11 Synchronized Collections 693
16.12 Unmodifiable Collections 693
16.13 Abstract Implementations 694
16.14 Java SE 9: Convenience Factory Methods for Immutable Collections 694
16.15 Wrap-Up 698

17 Lambdas and Streams 704


17.1 Introduction 705
17.2 Streams and Reduction 707
17.2.1 Summing the Integers from 1 through 10 with a for Loop 707
17.2.2 External Iteration with for Is Error Prone 708
17.2.3 Summing with a Stream and Reduction 708
17.2.4 Internal Iteration 709
17.3 Mapping and Lambdas 710
17.3.1 Lambda Expressions 711
17.3.2 Lambda Syntax 712
17.3.3 Intermediate and Terminal Operations 713
17.4 Filtering 714
17.5 How Elements Move Through Stream Pipelines 716
17.6 Method References 717
17.6.1 Creating an IntStream of Random Values 718
17.6.2 Performing a Task on Each Stream Element with forEach and
a Method Reference 718
17.6.3 Mapping Integers to String Objects with mapToObj 719
17.6.4 Concatenating Strings with collect 719
17.7 IntStream Operations 720
17.7.1 Creating an IntStream and Displaying Its Values 721
17.7.2 Terminal Operations count, min, max, sum and average 721
17.7.3 Terminal Operation reduce 722
17.7.4 Sorting IntStream Values 724
Contents 17

17.8 Functional Interfaces 725


17.9 Lambdas: A Deeper Look 726
17.10 Stream<Integer> Manipulations 727
17.10.1 Creating a Stream<Integer> 728
17.10.2 Sorting a Stream and Collecting the Results 729
17.10.3 Filtering a Stream and Storing the Results for Later Use 729
17.10.4 Filtering and Sorting a Stream and Collecting the Results 730
17.10.5 Sorting Previously Collected Results 730
17.11 Stream<String> Manipulations 730
17.11.1 Mapping Strings to Uppercase 731
17.11.2 Filtering Strings Then Sorting Them in Case-Insensitive
Ascending Order 732
17.11.3 Filtering Strings Then Sorting Them in Case-Insensitive
Descending Order 732
17.12 Stream<Employee> Manipulations 733
17.12.1 Creating and Displaying a List<Employee> 734
17.12.2 Filtering Employees with Salaries in a Specified Range 735
17.12.3 Sorting Employees By Multiple Fields 738
17.12.4 Mapping Employees to Unique-Last-Name Strings 740
17.12.5 Grouping Employees By Department 741
17.12.6 Counting the Number of Employees in Each Department 742
17.12.7 Summing and Averaging Employee Salaries 743
17.13 Creating a Stream<String> from a File 744
17.14 Streams of Random Values 747
17.15 Infinite Streams 749
17.16 Lambda Event Handlers 751
17.17 Additional Notes on Java SE 8 Interfaces 751
17.18 Wrap-Up 752

18 Recursion 766
18.1 Introduction 767
18.2 Recursion Concepts 768
18.3 Example Using Recursion: Factorials 769
18.4 Reimplementing Class FactorialCalculator Using BigInteger 771
18.5 Example Using Recursion: Fibonacci Series 773
18.6 Recursion and the Method-Call Stack 776
18.7 Recursion vs. Iteration 777
18.8 Towers of Hanoi 779
18.9 Fractals 781
18.9.1 Koch Curve Fractal 782
18.9.2 (Optional) Case Study: Lo Feather Fractal 783
18.9.3 (Optional) Fractal App GUI 785
18.9.4 (Optional) FractalController Class 787
18.10 Recursive Backtracking 792
18.11 Wrap-Up 792
18 Contents

19 Searching, Sorting and Big O 801


19.1 Introduction 802
19.2 Linear Search 803
19.3 Big O Notation 806
19.3.1 O(1) Algorithms 806
19.3.2 O(n) Algorithms 806
19.3.3 O(n2) Algorithms 806
19.3.4 Big O of the Linear Search 807
19.4 Binary Search 807
19.4.1 Binary Search Implementation 808
19.4.2 Efficiency of the Binary Search 811
19.5 Sorting Algorithms 812
19.6 Selection Sort 812
19.6.1 Selection Sort Implementation 813
19.6.2 Efficiency of the Selection Sort 815
19.7 Insertion Sort 815
19.7.1 Insertion Sort Implementation 816
19.7.2 Efficiency of the Insertion Sort 818
19.8 Merge Sort 819
19.8.1 Merge Sort Implementation 819
19.8.2 Efficiency of the Merge Sort 824
19.9 Big O Summary for This Chapter’s Searching and Sorting Algorithms 824
19.10 Massive Parallelism and Parallel Algorithms 825
19.11 Wrap-Up 825

20 Generic Classes and Methods: A Deeper Look 831


20.1 Introduction 832
20.2 Motivation for Generic Methods 832
20.3 Generic Methods: Implementation and Compile-Time Translation 834
20.4 Additional Compile-Time Translation Issues: Methods That Use a Type
Parameter as the Return Type 837
20.5 Overloading Generic Methods 840
20.6 Generic Classes 841
20.7 Wildcards in Methods That Accept Type Parameters 848
20.8 Wrap-Up 852

21 Custom Generic Data Structures 856


21.1 Introduction 857
21.2 Self-Referential Classes 858
21.3 Dynamic Memory Allocation 858
21.4 Linked Lists 859
21.4.1 Singly Linked Lists 859
21.4.2 Implementing a Generic List Class 860
21.4.3 Generic Classes ListNode and List 863
Contents 19

21.4.4 Class ListTest 863


21.4.5 List Method insertAtFront 865
21.4.6 List Method insertAtBack 866
21.4.7 List Method removeFromFront 866
21.4.8 List Method removeFromBack 867
21.4.9 List Method print 868
21.4.10 Creating Your Own Packages 868
21.5 Stacks 873
21.6 Queues 876
21.7 Trees 878
21.8 Wrap-Up 885

22 JavaFX Graphics and Multimedia 910


22.1 Introduction 911
22.2 Controlling Fonts with Cascading Style Sheets (CSS) 912
22.2.1 CSS That Styles the GUI 912
22.2.2 FXML That Defines the GUI—Introduction to XML Markup 915
22.2.3 Referencing the CSS File from FXML 918
22.2.4 Specifying the VBox’s Style Class 918
22.2.5 Programmatically Loading CSS 918
22.3 Displaying Two-Dimensional Shapes 919
22.3.1 Defining Two-Dimensional Shapes with FXML 919
22.3.2 CSS That Styles the Two-Dimensional Shapes 922
22.4 Polylines, Polygons and Paths 924
22.4.1 GUI and CSS 925
22.4.2 PolyShapesController Class 926
22.5 Transforms 929
22.6 Playing Video with Media, MediaPlayer and MediaViewer 931
22.6.1 VideoPlayer GUI 932
22.6.2 VideoPlayerController Class 934
22.7 Transition Animations 938
22.7.1 TransitionAnimations.fxml 938
22.7.2 TransitionAnimationsController Class 940
22.8 Timeline Animations 944
22.9 Frame-by-Frame Animation with AnimationTimer 947
22.10 Drawing on a Canvas 949
22.11 Three-Dimensional Shapes 954
22.12 Wrap-Up 957

23 Concurrency 973
23.1 Introduction 974
23.2 Thread States and Life Cycle 976
23.2.1 New and Runnable States 977
23.2.2 Waiting State 977
20 Contents

23.2.3 Timed Waiting State 977


23.2.4 Blocked State 977
23.2.5 Terminated State 977
23.2.6 Operating-System View of the Runnable State 978
23.2.7 Thread Priorities and Thread Scheduling 978
23.2.8 Indefinite Postponement and Deadlock 979
23.3 Creating and Executing Threads with the Executor Framework 979
23.4 Thread Synchronization 983
23.4.1 Immutable Data 984
23.4.2 Monitors 984
23.4.3 Unsynchronized Mutable Data Sharing 985
23.4.4 Synchronized Mutable Data Sharing—Making
Operations Atomic 989
23.5 Producer/Consumer Relationship without Synchronization 992
23.6 Producer/Consumer Relationship: ArrayBlockingQueue 1000
23.7 (Advanced) Producer/Consumer Relationship with synchronized,
wait, notify and notifyAll 1003
23.8 (Advanced) Producer/Consumer Relationship: Bounded Buffers 1009
23.9 (Advanced) Producer/Consumer Relationship: The Lock and
Condition Interfaces 1017
23.10 Concurrent Collections 1024
23.11 Multithreading in JavaFX 1026
23.11.1 Performing Computations in a Worker Thread:
Fibonacci Numbers 1027
23.11.2 Processing Intermediate Results: Sieve of Eratosthenes 1032
23.12 sort/parallelSort Timings with the Java SE 8 Date/Time API 1038
23.13 Java SE 8: Sequential vs. Parallel Streams 1041
23.14 (Advanced) Interfaces Callable and Future 1043
23.15 (Advanced) Fork/Join Framework 1048
23.16 Wrap-Up 1048

24 Accessing Databases with JDBC 1060


24.1 Introduction 1061
24.2 Relational Databases 1062
24.3 A books Database 1063
24.4 SQL 1067
24.4.1 Basic SELECT Query 1068
24.4.2 WHERE Clause 1068
24.4.3 ORDER BY Clause 1070
24.4.4 Merging Data from Multiple Tables: INNER JOIN 1072
24.4.5 INSERT Statement 1073
24.4.6 UPDATE Statement 1074
24.4.7 DELETE Statement 1075
24.5 Setting Up a Java DB Database 1076
24.5.1 Creating the Chapter’s Databases on Windows 1077
Another Random Scribd Document
with Unrelated Content
They pulled up together beside the strange object, and 183
Captain Cornell stirred it with a foot. “Come out,” he
commanded in Spanish, “and have a care. I am armed.”

The faded carpet covering what they now could see was
a man out-stretched his full length, quivered. But no
man emerged.

“I’ll cover him, Frank,” said Captain Cornell. “Do you


take off the carpet.”

Frank seized an end of the carpet and tugged. But the


carpet did not come away. Instead, the object beneath
began to roll toward him. A man was rolled up inside.
Once, twice, he turned over. Then the end of the carpet
was reached, and the man lay exposed.

“By the ring-tailed caterpillar,” cried Frank, using his


wildest expletive. “It’s Don Ferdinand.” And he flung
himself on his knees, and began fumbling at the knotted
rope wound ’round and ’round the form of his old
acquaintance, who was trussed from head to heel.
“Lend a hand, Captain. Or, wait, I’ll cut those ropes.”
And he fished for his pocket knife, and getting it out,
opened and began to slash the bonds. A moment later
he desisted in order to pull away the huge bandanna
knotted about the aristocratic Don Ferdinand’s jaw and
efficiently stopping speech. The moment the gag was
withdrawn, the old Don began to sputter.

“Hey, Captain,” Frank cried excitedly, “run to the edge of 184


the roof and call out to the fellows.”

And as Captain Cornell hastened away to comply, Frank


finished the task of releasing the Don and then assisted
him to his feet. Don Ferdinand was so stiff from his
bonds as to be unable to stand without assistance. But
his tongue wasn’t stiff. It rattled on at a great rate.
Frank, whose Spanish was somewhat rusty from disuse,
had difficulty in understanding, so voluble was the Don’s
speech. He knew, however, that his old friend was
pouring vials of wrath on the head of the missing
Ramirez; and he was tempted to smile, but by an effort
managed to refrain.

In the mean time, he assisted Don Ferdinand to the


open trap door, impressing on him that Ramirez had fled
and that friends waited below. They were joined by
Captain Cornell, who helped Frank lower the older man
to the stool below. Thereupon the two followed, pulling
the trap shut behind them. Captain Cornell urged haste.

“Let’s get out of this and get back to our own land,” he
said. “We’ve rescued Don Ferdinand, thanks to you
Frank. It would be a shame to get into trouble with the
authorities now.”

Frank agreed, and with a hand under Don Ferdinand’s 185


elbow hurried the frothing old aristocrat down the stairs.
Not once did the latter cease his wrathy outpourings
until they emerged on the street, where Mr. Hampton
was first to greet them. But Captain Cornell interrupted
the conversation between these two old friends before it
could get well launched. He was impatient to be gone.

“We’ve had a lot of luck,” he said, “but it may not last. I


don’t know what is the standing of this fellow Ramirez
with the Mexican authorities. He may own the town, for
all I know. Anyway, it would be a shame for us
American officers to get into trouble over here now.
Let’s go.”
They went. Somehow or other, the party which had
come in the big car of the flyers and the Laredo taxicab,
augmented now by the addition of Bob and Captain
Cornell and Don Ferdinand, managed to swarm into the
constricted space. It was a wild race for the Bridge, and
so jounced about was everybody that ordered
conversation was impossible.

“Pull up at the Hamilton, everybody,” Mr. Hampton had


said, on starting. “Then we can have a council of war
and hear Don Ferdinand’s story.”

So, although the car containing the flyers, drew rapidly 186
ahead, those in the taxi felt assured that they would all
be reunited, provided they managed to cross the
International Bridge without running foul of the Mexican
authorities. This they did, just ahead of the procession
of cars coming from the bull fight. And in the lobby of
the Hamilton, Don Ferdinand and his escorts found the
men of the Border Patrol awaiting them.

“Whew,” said Captain Murray, as they trooped into Mr.


Hampton’s sitting room, to the amazement of Mr.
Temple who had spent the afternoon in a quiet siesta
which their coming rudely routed; “that was a risky
piece of business. We had no business invading Mexico,
and if we had been caught at it by the authorities of
Nueva Laredo we would have had to do some tall
explaining. Glad it’s over—and without exposure.”

“I’ll not forget, old man,” said Captain Cornell.

“Rot.” Murray playfully pulled the other’s hat down over


his eyes. “You’d do as much for any of us.”

Around the big room they all found seats, the seven 187
young aviators of the Border Patrol, the Hamptons, the
Temples and Frank, many sitting on the floor. Don
Ferdinand was given the seat of honor, a huge winged
arm chair. Perhaps, he would prefer to rest after his
trying experiences rather than to talk, suggested Mr.
Hampton; in which case they would permit him to
retire, and he could relate his story later. But the old
aristocrat waved that suggestion aside impatiently. He
was filled with anger and eager to talk. Perhaps, too,
added Mr. Hampton, he was hungry and would like to
eat. But to that, too, the old Don said, no. Mr. Hampton
did, however, ring for bottled ginger ale which when it
arrived everybody eagerly seized.

Then with bottles in hand, they listened while Don


Ferdinand explained how he had come to be in the
predicament from which Frank and Captain Cornell had
rescued him.

To begin with, Ramirez, as they already knew, had lured


away a score of men from Don Ferdinand’s mine in the
mountains, many miles to the west. The old Don feared
Ramirez was preparing to gather a rebel army and
launch a new rebellion. At one time, nothing would have
pleased Don Ferdinand better. But he believed now that
the Obregon government was stabilizing his country,
and he wanted its peace to continue undisturbed.

In that isolated district, there was only a shadow of


Federal authority, in the form of a commander and a
score of troops in a small town garrison at the village of
San Dimas. Don Ferdinand decided that it would be
useless to appeal to such help, for in the meantime
Ramirez would move eastward unhampered and
continually gathering more troops. Accordingly, with his
own followers at his back, he set out in pursuit.
Well mounted though they were, however, Don 188
Ferdinand’s command failed to catch up with Ramirez.
Through sparsely settled country, where the only human
inhabitants were a few lonely sheepherders, led the
chase. Now and then Don Ferdinand obtained word of
Ramirez’s passing. Once, about fifty miles west of Nueva
Laredo, they came upon a camp which Ramirez had
made along the Rio Grande that was only a day old. The
American town of Carana, a Texan village inhabited by
Mexicans, was not far distant across the river. Then they
pressed on toward Nueva Laredo, hopeful of meeting
Ramirez before he could gain sufficient strength to
attack the town.

But almost at once Don Ferdinand discovered that


Ramirez no longer had with him the main body of his
followers. Trail signs up to the last camp had indicated
that more than a score of men rode with Ramirez. Now
the signs showed that not more than four horsemen
had proceeded from the last camp. They turned back at
once in order to make a closer inspection of the
camping place, and soon discovered that the score left
behind had crossed the river in the direction of Carana,
some three miles away.

This puzzled the old Don sadly. A dozen conjectures as 189


to the reason for such a move whirled through his brain.
The one most likely to be true, he believed, was that
Ramirez had sent his main body along the deserted
Texan shore toward Nueva Laredo while he and a few
lieutenants approached it from the Mexican side. Many
Mexicans live in Texas; and, therefore, the followers of
Ramirez would be able to enter Laredo without
detection and stay in the American town until they
received word from their commander to enter Mexico.
In the mean time, Ramirez could be preparing his plans
in Nueva Laredo for a surprise attack that would put the
town in his power. So Don Ferdinand pressed eagerly
toward Nueva Laredo. He felt that this move would
make the capture of Ramirez all the easier, and that
with the brains of the revolution laid by the heels, there
would be no revolution.

Five miles from Nueva Laredo, Don Ferdinand left his


followers at the hacienda of a friend. Only one man did
he take with him, whose duty it would be to act as
messenger and summon the troop in case of need. He
entered Nueva Laredo the next day and spent hours in
making guarded inquiries.

No information. At least, none of value. Don Ferdinand 190


had acquaintances in Nueva Laredo. His land-owning
friend had others to whom he bore references. All knew
of Ramirez and his former reputation as a smuggler and
bad character. None, however, had heard of any
revolutionary movement with him behind it, and only
one had heard of his being in Nueva Laredo. He had
been seen on the street, somebody had dropped
mention of it to this informant.

Don Ferdinand pressed his inquiries further. Believing


Ramirez’s command had crossed the Rio Grande fifty
miles west in order to march into Laredo and there
await word from their commander, he went to Laredo. A
very good friend, a wealthy merchant, housed him. But
inquiries made amid the lower strata of Laredo society
by the merchant’s employees brought forth no
information regarding an influx of strangers who might
be Ramirez’s men. Then, driving across the International
Bridge, Saturday night, Don Ferdinand in his friend’s car
caught sight of Ramirez, only to lose the chase, as
already narrated, through his accidental smashing into
the taxi of his young friends.

The next day was the morning of the bull fight. 191
Remembering his promise to call at the Hamilton Hotel
Don Ferdinand was preparing for the visit when word
was brought him that Ramirez had been located in a
house on Calle Libertad. The informant was one of his
merchant-friend’s employees—a laborer from the
warehouse. He undertook to guide Don Ferdinand to a
dive in Nueva Laredo, where they were to meet one of
Ramirez’s men who had agreed to sell his information, if
Don Ferdinand would buy. The merchant was asleep.
Don Ferdinand did not wake him, but took the car which
had been placed at his disposal and drove with his
informant to the meeting place.

“It was a trick,” he explained. “Barely had I entered the


dive than I was seized from behind, gagged and then
taken in my friend’s car to the house in Calle Libertad.”

“And Ramirez?” questioned Mr. Hampton.

“At the house he met me. Our conversation I shall not


repeat. It would only bore you. But, Senor Hampton, my
good friend, I must tell you I was mistaken. This devil
Ramirez, he think he have me in his power and can tell
me all. Ah, he does not realize I have good friends who
will come to my rescue. What do you think, Senor? He
says he does not make the revolution; there is no
money in that. Instead, he organized a—what shall I call
it?—system of men for smuggling Orientals out of
Mexico into the Estados Unidos.”

“An underground railway?” suggested Captain Cornell.

Don Ferdinand nodded.


“I was surprise’—me. He think, this devil Ramirez, it is I, 192
Don Ferdinand, who want a share in this traffic which is
so profitable. He think it is because of that desire for
money that I pursue him. So now he capture me.”

Don Ferdinand’s listeners betrayed the keenest interest.


Captain Cornell was especially eager for details. His
suspicions regarding Ramirez and the latter’s projects
were fulfilled. He wanted to know all. Questions poured
upon Don Ferdinand in a flood, completely
overwhelming him. At length he waved his hands
impatiently.

“Senors, have a patience. There is little more to tell.


This devil, Ramirez, he reveal that he take my man from
the mine because he need men for his—what you call?
—oh, yes, his underground railway. When he send them
across Rio Grande, it is that they go to Carana and
prepare. From Carana, these Orientals shall be sent to
San Antonio and then distributed through Estados
Unidos.”

“But didn’t he have other men?” asked Mr. Hampton.


“Why should he go west to your mine, and take your
men? Why should he take my cook Ramon?”

“About thees Ramon, I do not know. But Ramirez, he


take my men because he know I shall pursue. Me, he
have a grudge against this long time.”

193
CHAPTER XXI.
ON RAMIREZ’S TRAIL.

Jack had been listening but at the same time his


thoughts had been busy with conjectures. To him, it did
not seem likely that Ramirez had laid his plans solely in
order that he might lure Don Ferdinand into his power.
Some other motive there must be. And his thoughts
leaped to Rafaela. With the departure of her father and
the major portion of his men, she would be left with but
slim protection in her mountain fastness. Was it possible
that Ramirez had deliberately planned affairs so that she
should be left defenceless? He could not understand
why this supposition occurred to him, not realizing that
Rafaela was in the background of all his thoughts of late
to a greater extent than he appreciated; but occur it
did. And now he remembered, too, that when leaving
home to fly to Laredo, he had been unable to gain a
response to his radio calls to Rafaela.

Was it possible that already evil had befallen her? A 194


sudden fear clutched at his heart. The others were
talking among themselves, excitedly. Snatches of their
conversation informed Jack that the aviators of the
Border Patrol were discussing this turn of events and
what it would mean for them, inasmuch as it placed in
their possession the clew to a traffic in human
contraband which would have to be broken up. Don
Ferdinand for the moment no longer occupied the
center of attention, and Jack, noting this, slipped
around behind his chair and leaning over the back of
the chair, addressed him in a low voice.

The old man listened a moment and then looked up


startled, while over his features came an expression of
alarm. He half started out of his chair.

“Jack, I am the fool,” he said. “That devil Ramirez, he


have seen my daughter two-three month ago at the
fiesta and have try to kees her. My men, they have beat
him. He nurses revenge. It is for that revenge I think he
try to get me in his power. But, no, it is that he may
carry off my daughter while I am away. Fool, fool,” he
cried, and struck his head with his clenched fist. Then
his eyes brightened.

“But, no, Jack. If he want to carry off my daughter, why


is he here?”

“I thought of that, too,” replied Jack. “But maybe he is 195


trying to combine business with pleasure. While he
conducts his smuggling operations, and lures you out of
the way in pursuit of him, some lieutenant may be
swooping down and carrying Rafaela away.”

Don Ferdinand frowned, twisting his mustaches


ferociously. “He is a devil. He is smart as Satan himself.
Perhaps, it is that you are right, Jack.”

Jack persisted. “Look here, Don Ferdinand. This fellow


Ramirez had a band with him before he took your men
away from the mine, didn’t he? Well, if he took a score
from you, and that’s about all he brought this way with
him, he must have left others behind in the mountains.
He—”

“Enough, Jack. You are right.” Don Ferdinand leaped to


his feet. “Fool, fool,” he cried again, once more striking
his head.

At this gesture and outburst the others gained their feet


and gathered around the pair, demanding to know what
was the matter. As briefly as he could, Jack explained.
In conclusion he added that so far as he could see, the
first thing to do was to get into communication with Don
Ferdinand’s ranch. Radio was the only means.
Therefore, he would have to go at once to the flying
field in order to call the ranch station.

The big fellow was dismayed. His handsome features


were flushed. And his father, knowing more than the
others of how Jack’s affections were involved, moved to
his side and threw an arm across his shoulders.

“Easy, son,” he said. “If Ramirez intended to carry off 196


Rafaela, he would have boasted of it to Don Ferdinand
when he had our friend in his power.”

“Maybe so, Dad,” said Jack. “On the other hand,


Ramirez might have been saving up that choice bit of
information for a denouement. Anyhow, I think the best
thing to do is to try and get in touch with Rafaela at
once.”

“If you can’t get an answer, Jack,” Frank suggested,


“suppose we fly out there in your plane.”

At that Captain Cornell shook his head. “It’ll be dark in


another two hours,” he said. “And you couldn’t get
started under an hour from now. The flight would take
three hours. It would be folly to make the trip in your
plane, Jack. You may know all that country well, but
landing at night is a very different matter from making a
daylight landing. If you were forced down, hm!” He
shrugged his shoulders and spread out his hands in an
eloquent gesture.

“There’s a landing field at Don Ferdinand’s,” Jack


expostulated. “And nothing would go wrong that would
force me down between here and there.”

“You never can tell,” said Captain Cornell. “Besides,” he 197


added, turning to the others, “we have something else
to think about. Don Ferdinand,” he added, addressing
the latter directly, “you were in that house longer than I.
Besides, Ramirez boasted to you of what he was
planning to do. Now I saw numerous pallets there,
indicating that a good many Orientals had slept there
only recently. Did Ramirez reveal what had become of
them and when he intended to try to smuggle them
over the Border?”

“They were taken out of Nueva Laredo last night,” said


Don Ferdinand. “That much, he tell me. One was
stabbed in a fight, but could walk. They are walking
toward Carana.”

“Not on horseback?”

“No. And he say, this devil Ramirez, that he will put


them across the Rio Grande tonight,” Don Ferdinand
added.

“Boys,” said Captain Cornell, decisively. “That means


work for us.”
The members of the Border Patrol nodded, their eyes
bright. All but Captain Murray. “But Ramirez knows we’ll
be on his trail,” he objected. “He knows we’re in it.
Otherwise, Cornell, why did he capture you?”

“Huh. He was in that crowd in Nueva Laredo last night, 198


when Don Ferdinand and the boys and I got together.
Saw me stop Don Ferdinand and bring him back. Then
he turned around and mixed in with the crowd. So he
knew Don Ferdinand and I were acquainted. When he
saw me examining his auto, out there in front of his
house, or rather, Don Ferdinand’s stolen auto, he socked
me. But—he doesn’t know I’m an aviator, or that you
fellows who came to my rescue are aviators. I guess
he’s still trying to figure out how you came to the
rescue.”

Captain Murray’s brow cleared. “Good. Then he doesn’t


know that the Border Patrol is on his trail. What a sweet
surprise we’ll spring on him at Carana. We’ll take your
ship and mine. I’ll telephone the field to warm ’em up—
and they’ll be ready when we arrive.”

He turned to the room telephone. Jack halted him. “Tell


them to warm my ship up, too, Captain, please,” he
begged. “If I can’t get Don Ferdinand’s daughter by
radio, I’ll have to fly over there.”

“One hundred and fifty miles,” interrupted Captain


Cornell. “And dark in little more than an hour from now.
You can’t do it, Jack. Night-flying is nothing for an
inexperienced man to undertake.”

“We’ll see,” said Jack. “Anyway, you have my ship


warmed up for me, please, Captain Murray.”
Leaving the room abruptly, with the remark that he
would return in a short time, Jack went toward his own
room on the same floor. A gabble of voices floated
upstairs from the lobby, where the bull fight of the
afternoon was under discussion. Frank and Bob, true
comrades, followed him.

“What you going to do, Jack?”

“Get a sweater and helmet.” Jack’s lips set in a grim 199


line.

“If you go, we’re going with you.”

“We’ll talk about that later. Thanks, though, fellows.”

As they returned, the aviators were emerging into the


hall. With them were Mr. Hampton, Mr. Temple and Don
Ferdinand, all wearing anxious faces.

“Here he is,” cried Captain Cornell. “Listen, Jack. We’ve


decided what to do.”

The two groups faced each other.

“It wouldn’t do, Jack, it wouldn’t do at all, for you to fly


in your boat to Don Ferdinand’s. Your boat is all right, I
know, a peach of a little craft. But it isn’t equipped with
a searchlight, and it’s too frail to be trusted in a forced
night landing. Besides, you haven’t any experience in
night-flying. So if it seems necessary to make a flight to
Don Ferdinand’s, you and I’ll go in a De Haviland.”

Jack’s face which had been growing more and more set
in a grim look of determination, lightened materially.
“Oh, say, Captain, that’ll be fine,” he said. “You’re a
white man.” And he gripped the other’s hand.
“Hm!” Captain Cornell grunted. “Come on, we’re all 200
going out to the field. The fellows have their car at the
door, and we’ve ordered a couple of taxis.”

In the hotel lobby, the group attracted considerable


attention from the various groups of old-timers and
tourists scattered about. Jack Hannaford, the old ex-
Ranger, huge, grizzled, mustached, strode up to Captain
Cornell.

“Howdy,” he cried. Then in a lower voice, he added:


“Looks like trouble for somebody, when doggone near
the whole Laredo flight of the Border Patrol puts its
heads together. Got something you can let me in on?”

The others were going on. Captain Cornell was tempted


to tell Hannaford of the expedition that was afoot. He
liked the old Ranger. No harm could be done by it. On
the other hand, nothing was to be gained. And his
companions were waiting for him.

“Yes, a little expedition up the river, Hannaford,” he said.


“I’m in a hurry. Excuse me now, and I’ll tell you about it
later.”

Hannaford stepped closer and dropped his voice still


lower. “Is it about Ramirez?” he asked. “You was asking
’bout him yestiddy, you know.”

“Ramirez?” gasped Captain Cornell. “Yes, Hannaford, it


is. What do you know about him?”

“Nothing much,” said Hannaford, in a deceptively


indifferent voice. “Only I know where he is.”

“You know where he is.” 201


“Uh. Doc Garfield jist telephoned me, right here in the
lobby, that he got Ramirez in his office. The duck come
in with a bullet through his arm. Broken. Wanted it set.”

“Hampton’s bullet did that. Doc Garfield? Where? Here


in Laredo?”

“Uh-huh. Down near the Bridge.”

“Great guns.” The excited Captain Cornell stared


incredulously at his informant. “Why’d this doctor call
you?”

“Good friend o’ mine. Knows I got a grudge to settle


with Ramirez. Wanted to know if there was any warrant
out for him. Doc Garfield, he’s an old-timer. Knows these
Border ruffians, most of ’em, by sight, anyways.”

“And you told him—”

“Tol’ him? What could I tell him? Tol’ him they was no
warrants out that I knew of. But I was on my way to
light out for Garfield’s when I see you come inta the
lobby. Jist hung up the ’phone.”

“Hannaford, listen. No, wait a minute. My friends must


hear of this. Oh, shucks, come with me. That’s the best
way.”

Captain Cornell seized the old ex-Ranger by an arm and


half-urged, half-drew him out of the lobby to the street.

202
CHAPTER XXII.
TO THE RESCUE.

Two taxicabs and the big touring car from the aviation
field, his friends in them and anxious to go, stood at the
curb as Captain Cornell with Hannaford beside him,
came down the steps.

“Snap into it, Cornell,” called Captain Murray,


impatiently. “Get into one of the taxis. We’re loaded.”

He stepped on the starter and the big car began to roar.


Captain Cornell cleared the sidewalk in one jump, and
landed on the running board. “Stop your engine. I’ve
got news.”

“News?”

“You bet.” The excited Captain Cornell turned toward


the two taxis and waved their occupants to approach.
The three boys who were in the nearer taxi were by his
side in a moment, for they sensed from his manner that
he had something important to divulge. The three older
men who were in the farther taxi were slower to
approach. Yet they, too, hurried their pace on noting
Captain Cornell’s air of suppressed excitement.
“Fellows,” he said, low-voiced, as the tense group 203
gathered around him and Hannaford, “I know where
Ramirez is. And we’re going for him right away.”

Quickly he explained what Hannaford had just revealed


to him.

“And don’t worry none about bein’ legal,” said


Hannaford. “I’m a deputy sheriff, and bein’ as how you
got somethin’ on Ramirez which makes it all right for us
to go after him, I’ll swear you all in as members o’ my
posse.”

“All right, Hannaford, step on it,” said Captain Murray.


“Climb in with us, and show us the way.”

Hannaford was bundled into the foremost car, Captain


Cornell joined the boys in the first taxi, and both cars
got off to an almost equal start. That bearing Mr.
Hampton and Mr. Temple and Don Ferdinand was slower
in getting under way, but kept the others in sight.

“This shoulder of mine has felt better in its time,”


grunted Mr. Hampton to his companions. “I planned to
wait until we got to the flying field, where I could have
the flight surgeon examine and treat it, and wouldn’t
have to make embarrassing explanations. But, maybe,
this Doctor Garfield can fix me up.”

Several minutes later found the three cars drawn up 204


together on a deserted side street near the International
Bridge. Hannaford had called a halt. Doctor Garfield’s
home and office lay in the next block, and the old ex-
Ranger felt it was necessary to prepare a plan of
campaign before going farther.
“Doc Garfield was in a hurry when he phoned,” said
Hannaford. “I know where his phone is—in a little room
separated from his office. He was speaking low and
hurried, while Ramirez waited. Doc couldn’t tell me
much, only that Ramirez come in a car which he left
standing at the curb, and he thinks there’s a woman in
the car and a couple or three men.”

“This doctor, his office it is in the next block?” asked


Don Ferdinand. Jack Hannaford nodded. “It grows
dusk,” said the old Don, “but,” he added, in a tone of
conviction, “but I am certain that ees my friend’s car I
see.” He pointed.

Twilight had come. Purple dusk lay over the quiet street.
Graceful pepper trees lining the curbing enhanced the
shadows beneath them. Yet it was not so dark but what
those who had seen it before felt pretty certain that the
car parked at the opposite curb in the next block was
that borrowed from his friend by Don Ferdinand and
stolen from the latter by Ramirez. The shadows were
growing deeper, yet the lines of the car and the
occasional glimmer of polished trimmings could not be
mistaken. Hannaford gave confirmation.

“That’s where Doc Garfield’s house is.” 205

“Look here,” said Jack, taking the initiative. “We’ve got


the advantage of surprise. They won’t be expecting us.
Let’s dash up beside them, and demand their surrender.
We’ll be on them before they can know what is
happening. Mr. Hannaford, who knows the house, can
lead a group inside in a dash that ought to bag Ramirez
without trouble, especially as he’s got a busted arm.”

Nobody could suggest any better plan.


“Furthermore,” said Jack, addressing the aviators, “the
car you fellows are driving better fall to the rear.
Ramirez’s men have seen it.”

Arrangements were quickly made, a number of aviators


transferring to the taxi previously occupied by the older
men, while Captain Cornell took his place in that
occupied by the three boys. One was to range up
alongside the stolen car, the other to draw up behind it,
whereupon its occupants could pile out and take the
gangsters on the other side. As for Hannaford and his
group, who were to enter the house, they were to go up
a side street and approach from the rear.

“Ramirez may see what’s going on out front, and take to


his heels out the back door,” said Hannaford. “If he
does, we’ll bag him.”

This arrangement was satisfactory to everybody except 206


the three older men. Mr. Hampton was regretful
because his wounded shoulder would keep him out of
action. Mr. Temple was plainly nervous and disinclined to
have the boys running into danger. And Don Ferdinand
bounced up and down, demanding a revolver, so that he
could take a hand in the fray. But there was none to
spare, and he and his two companions were to stay in
the aviators’ car. As for the drivers of the two rented
taxis, they were not without experience in affrays of one
sort and another in this tempestuous community, and
their fares were sufficient guarantee that they would be
compensated for any damages sustained. Moreover,
they knew Jack Hannaford, whose word with them was
law.

“Let’s go,” said Captain Cornell, impatiently.


The discussion of details, quickly though the latter had
been arranged, had consumed several minutes. Dusk
was deepening. Jumping into the leading taxi, Captain
Cornell seated himself beside the driver, a position
which fortunately would put him next to the car ahead.
The boys were in the rear compartment, Jack crouching
by the door and ready to throw it open and leap out at
the crucial moment.

In such tense moments, it is emotion, not reason, which 207


sways one. Certainly, Jack was in the grip of strong
emotion. Certainly, the others were, too, as they bore
down upon the car ahead. But how different in every
case! Jack was filled with rage bordering upon despair
as he thought of the possibility that Rafaela might have
come to harm through the machinations of Ramirez. His
whole idea was to lay hands on Ramirez at the earliest
possible moment and to choke the truth out of him, to
force him to confess where he had hidden Rafaela, if he
or his lieutenants had stolen her from her home during
her father’s absence. To none of the others, except
Rafaela’s father, no, not even to Jack’s two comrades,
did the affair appear in the same light as to him. They
likewise were stirred by emotions, but only such as are
incident to men hunting a criminal, in whose evil-doing
their own personal fortunes or the fortunes of dear ones
are not involved.

Only a very brief space of time was required to cover


the ground intervening between the last halting place
and the field of action, and, before the two taxis closed
on the car ahead, the big car from the aviation field,
under command of Jack Hannaford, swung into the
intervening cross street. Mr. Hampton, who was among
its occupants, shook his head as he lost sight of his son.
He knew, if nobody else did, how Jack was shaken
emotionally.

Hannaford pointed and, at his accompanying word of 208


command, the young aviator at the wheel swung the
car to the curb. Then the grizzled old Texan and the
aviator—it was young Harincourt who had been detailed
to this task—leaped out. Quickly he outlined his plan.

They were at the mouth of an alley running along the


rear of Doctor Garfield’s house. Hannaford and young
Harincourt would enter the house from the rear. Mr.
Hampton, Mr. Temple and Don Ferdinand were to keep
guard at the alley’s mouth. If Ramirez escaped
Hannaford and came down the alley, it would be their
job to pot him. Don Ferdinand, raging, protested. He
wanted to be in the forefront.

“Two’s enough,” said Hannaford brusquely. “More would


git in their own way. You stay here. Come on, lad.”

And with Harincourt at his heels, the old ex-Ranger


darted up the deserted narrow alley, in which the
shadows were deepening at the near approach of night,
as briskly as a boy.

Mr. Hampton shook his head in admiration, a little smile


on his lips.

“A tough breed,” he commented.

In the meantime, up the shadowy street in front of the 209


house, with its air of Sabbath calm, sped the two taxis,
while peal on peal of bells from the tower of a nearby
church floated down on the still air. What irony, thought
Jack, church bells and he and his comrades speeding on
such a mission! Yet their mission was of the best, he
comforted himself.

And then all thought except of the matter in hand fled,


crouching against the door, ready to fling it open and
spring out, his eyes, just tipping the rim of the panelled
glass, beheld the other car at the curb, ahead, abreast.
Now, now. As the brakes squeaked, and the taxi ground
to a stop so suddenly as to fling all its occupants about,
Jack thrust the door outward and sprang upon the
running board of the other car, pistol in hand. Beside
him was Captain Cornell, leaping down from the driver’s
side, and at his back Bob and Frank, crowding close.

But what was this revealed in the depths of that other


car? What, but one man struggling desperately yet
unavailingly in the grasp of another? And of a third man
cowering in a corner, with his upflung arms protecting
his face, while over him bent a fury in woman’s clothes,
one hand gripped in his hair and the other reaching
talon-like for his features?

Ramon, the Hamptons’ old cook, face distorted. “Senor


Jack, queek or he escape. I—cannot—hold—heem—”

And then Captain Cornell’s pistol butt falling on the head 210
of him whom Ramon clasped, and the other lying still
and Ramon rising to his knees with a sob of
thankfulness.

And then, wonder of wonders, the fury faced about, and


it was Rafaela. Rafaela, her face appearing as through a
mist to Jack’s unbelieving eyes. And quick as thought he
threw an arm about her and drew her close, while all
the fighting fury which had nerved her to the attack
went out of her, and she collapsed with a little trembling
cry. And Bob and Frank, over there, on the other side of
the car—though how they got there was a mystery to
Jack!—sitting on the form of the ruffian whom Rafaela
had faced and outfaced and at their back, only half-seen
in the growing darkness, the other aviators from the
second taxi.

“Is it all over? Anybody hurt?” the young aviators


demanded.

But Jack could think of nothing except that here was


Rafaela whom he had thought far away, and safe in his
arms, when he had feared she was in Ramirez’s power.
Safe in his arms—

For the first time he was aware of the broad grins upon 211
the faces of his two comrades, and the scarcely less-
pronounced smiles of his Border Patrol friends. He knew
the reason, but he merely pressed Rafaela tighter in the
circle of his arm. It was she who pulled away, with a
“Thank you, Senor, but I can stand now.” And then—
they were now in the street between car and taxi—the
little witch must needs add, as if utterly surprised, “Oh,
it is you, Jack.” And Jack, looking no more foolish than
he felt, could only add, “Yes, it’s I. Who—who did you
think it was?”

The grins became broader, someone laughed. Rafaela


only shrugged.

Across the embarrassment cut Captain Cornell’s voice.


“Tie ’em up, boys, and into the house, quick.”

“Oh, but, Senor, not Ramon,” protested Rafaela, facing


the group about the volubly expostulating cook. The
two other captives were sullen and silent. “He have
been of a help to me.”
“Senor Jack,” Ramon held out supplicating hands.

Jack hesitated, but the old cook’s appeal coupled with a


glance from Rafaela decided him. “I’ll answer for
Ramon,” he said.

And Bob, remembering the old cook’s recalcitrance


toward Ramirez outside the bull ring that afternoon—
was it only a few short hours before?—spoke up with,
“He’s all right. Let’s beat it into the house.”

A swirl and a whoop, a patter of running feet, and away 212


dashed the others, up the walk toward Doctor Garfield’s
house behind a wide lawn. The two hastily yet securely-
trussed captives lay on the sidewalk, with Ramon
leering about them, lighting a cigarette. The taxi driver
looked down interestedly from his seat at the two young
people standing so close to each other between his cab
and the other car.

“Aw, rats,” he muttered, but grinning as he spoke the


words. “Ain’t they the sweet young things.”

Then he climbed down stiffly and walked around on the


other side of his taxi to talk to his brother chauffeur in
the other car.

213
CHAPTER XXIII.
RAMON TALKS.

The rest can be briefly told. When the reserves, so to


speak, entered Doctor Garfield’s office, they found
Ramirez already captive in Hannaford’s clutches. The
Mexican had been in the act of departing, he was, in
fact, already at the front door, his hand on the knob,
when the old Texan from the rear had commanded him
to surrender.

Don Ferdinand, raging, had broken away from the


restraint of Mr. Hampton and Mr. Temple, and had
followed in the wake of Hannaford and young
Harincourt. He stood, trembling with passion, in front of
Ramirez, as the aviators under Captain Cornell, and ably
supported by Bob and Frank, appeared in the doorway
of the office.

“My daughter?” he was demanding, shaking his fist


under Ramirez’s nose. “Where is my daughter?”

And the latter, his evil eyes gleaming from his swarthy
face, was leering down at the smaller man.

“Where you cannot find her,” he was saying, for he 214


believed that his shout of warning, emitted as
Hannaford captured him, had been heard and heeded
by the captors of Rafaela who were in the car outside.

But the malicious triumph that shone from his eyes


departed when his attention was drawn by the loud
trampling of feet in the hall and he swung around to
face newcomers in the doorway. If these were more
Americans from the front of the house, it was likely that
his men had been captured and Rafaela rescued, was
the thought that followed. And this suspicion of the
downfall of his rascality was confirmed when Bob
stepped up to Don Ferdinand.

“Don’t believe him, sir,” said the big fellow. “Your


daughter is safe outside. Jack is with her.”

The last words fell on unheeding ears. Don Ferdinand


went through the crowd and out the hall like an arrow.

Much had been done, but something still remained.


Ramirez and several of his lieutenants had been
captured, and Rafaela rescued. But a score of Ramirez’s
followers were still at large, and the large band of
Orientals whom Ramirez was smuggling into the United
States in defiance of the immigration laws would have
to be rounded up before the Border Patrol would
consider its efforts a complete success.

“You see, it’s this way,” Captain Cornell hurriedly 215


explained to Jack and his comrades; “the new
immigration law which is under discussion in Congress
right now proposes a practically complete ban of
Orientals. Few enough have been admitted heretofore,
the majority being permitted to enter under a so-called
gentlemen’s agreement, and posing as students. Well,
some have been students, but certainly not all.
“Now,” he added, “if you are not familiar with what is
going on, I can tell you that our government is
preparing to frame a law which will make it impossible
for Orientals to enter our country. There have been
frequent rumors of late to the effect that the Orientals
were leaving their crowded home lands and migrating to
Mexico, where there is no ban against them, in large
numbers. Doubtless, Ramirez, who has a head on his
shoulders, even if he does use it only for rascality, and
who keeps abreast of the times, saw his opportunity in
this situation. He has planned an ‘underground railway’
for running Orientals out of Mexico and into the United
States. There used to be a traffic in the same sort of
human contraband on the Pacific Coast, until it was
broken up a few years ago. But,” he interrupted,
surprised, “why these knowing looks at each other?”

His listeners laughed. “You tell him, Jack,” said Bob. 216

“Well, Captain,” said Jack, “you may not believe it, but
we three happened to have a hand in breaking up that
traffic. And a sweet time we had of it, too, for a while.
By accident, we stumbled on something in San
Francisco which made us dangerous to the Smuggling
Ring. They kidnapped us and took us to sea. But we
managed to escape and to bring the government forces
down on their hiding place in the Santa Barbara Channel
islands. Fellows,” he added, addressing Bob and Frank,
“do you remember that inventor—Professor What’s-his-
name, and his radio finder for locating uncharted
stations? That’s how we managed to find the hiding
place, Captain, through locating their radio calls
between a shore station and their boats.”

“Those were the happy days,” said Bob reminiscently,


and a faraway look came into his eyes as his thoughts
turned back to the exciting events narrated in The Radio
Boys on Secret Service Duty.

Frank nodded. “Lots of fun,” he said.

Captain Cornell threw up his hands in mock dismay, as


he laughed. “You three must be regular trouble-finders,”
he commented. “Do you always get into the thick of
things like this?”

“Oh, not always,” said Jack. And Bob grumbled: 217

“Thick of things? Huh. We aren’t in the thick of things


this time. You fellows flying to Carana are going to get
the cream of the whole affair.”

The conversation had been conducted in undertones. All


four were standing on the outskirts of the group in
Doctor Garfield’s office, which was brilliantly lighted
while in one corner Captain Murray, finding he could
obtain little information from the sullen Ramirez, was
now pumping Ramon. Don Ferdinand had taken Rafaela
to the home of his merchant friend, and the boys were
to call on them on the morrow. Doctor Garfield had re-
dressed Mr. Hampton’s wound, and the latter had
departed for the hotel, accompanied by Mr. Temple, for
the express purpose of trying to locate the owner of the
flivver which Bob and Captain Cornell had made off with
outside of the Nueva Laredo bull ring that afternoon, in
their pursuit of Ramirez, and of reimbursing him.

The other aviators were listening to Captain Murray’s


attempt to obtain information from Ramon. Presently
the latter turned away impatiently, and, his eyes lighting
on Jack, he beckoned him forward.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookluna.com

You might also like