100% found this document useful (7 votes)
34 views

PDF Functional Interfaces in Java: Fundamentals and Examples 1st Edition Ralph Lecessi (Lecessi Download

Fundamentals

Uploaded by

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

PDF Functional Interfaces in Java: Fundamentals and Examples 1st Edition Ralph Lecessi (Lecessi Download

Fundamentals

Uploaded by

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

Download the full version of the textbook now at textbookfull.

com

Functional Interfaces in Java: Fundamentals


and Examples 1st Edition Ralph Lecessi
[Lecessi

https://textbookfull.com/product/functional-
interfaces-in-java-fundamentals-and-examples-1st-
edition-ralph-lecessi-lecessi/

Explore and download more textbook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Microservices Patterns With examples in Java 1st Edition


Chris Richardson

https://textbookfull.com/product/microservices-patterns-with-examples-
in-java-1st-edition-chris-richardson/

textbookfull.com

Microservices Patterns With examples in Java 1st Edition


Chris Richardson

https://textbookfull.com/product/microservices-patterns-with-examples-
in-java-1st-edition-chris-richardson-2/

textbookfull.com

A Functional Approach to Java: Augmenting Object-Oriented


Java Code with Functional Principles 1st Edition Ben
Weidig
https://textbookfull.com/product/a-functional-approach-to-java-
augmenting-object-oriented-java-code-with-functional-principles-1st-
edition-ben-weidig/
textbookfull.com

Her Dirty Mafia Men at Work 7 1st Edition Mika Lane

https://textbookfull.com/product/her-dirty-mafia-men-at-work-7-1st-
edition-mika-lane/

textbookfull.com
Transdisciplinary Theory Practice and Education The Art of
Collaborative Research and Collective Learning Dena Fam

https://textbookfull.com/product/transdisciplinary-theory-practice-
and-education-the-art-of-collaborative-research-and-collective-
learning-dena-fam/
textbookfull.com

Breast Diseases An Evidence Based Pocket Guide Guilherme


Novita

https://textbookfull.com/product/breast-diseases-an-evidence-based-
pocket-guide-guilherme-novita/

textbookfull.com

Women Writing the Neo-Victorian Novel: Erotic "Victorians"


Kathleen Renk

https://textbookfull.com/product/women-writing-the-neo-victorian-
novel-erotic-victorians-kathleen-renk/

textbookfull.com

Hyphenations of Capillary Chromatography with Mass


Spectrometry 1st Edition Peter Q. Tranchida (Editor)

https://textbookfull.com/product/hyphenations-of-capillary-
chromatography-with-mass-spectrometry-1st-edition-peter-q-tranchida-
editor/
textbookfull.com

Gandhi an illustrated biography First U.S. Edition.


Edition Gandhi

https://textbookfull.com/product/gandhi-an-illustrated-biography-
first-u-s-edition-edition-gandhi/

textbookfull.com
Core Data By Tutorials Aaron Douglas

https://textbookfull.com/product/core-data-by-tutorials-aaron-douglas/

textbookfull.com
Functional
Interfaces
in Java
Fundamentals and Examples

Ralph Lecessi
Functional Interfaces
in Java
Fundamentals and Examples

Ralph Lecessi
Functional Interfaces in Java: Fundamentals and Examples
Ralph Lecessi
Kendall Park, NJ, USA

ISBN-13 (pbk): 978-1-4842-4277-3 ISBN-13 (electronic): 978-1-4842-4278-0


https://doi.org/10.1007/978-1-4842-4278-0
Library of Congress Control Number: 2019932794

Copyright © 2019 by Ralph Lecessi


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Steve Anglin
Development Editor: Matthew Moodie
Coordinating Editor: Mark Powers
Cover designed by eStudioCalamar
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street,
6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-
sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member
(owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a
Delaware corporation.
For information on translations, please e-mail editorial@apress.com; for reprint, paperback, or audio rights,
please email bookpermissions@springernature.com.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/9781484242773. For more
detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
Table of Contents
About the Author��������������������������������������������������������������������������������������������������� xiii

About the Technical Reviewer���������������������������������������������������������������������������������xv


Foreword���������������������������������������������������������������������������������������������������������������xvii

Chapter 1: Functional Interfaces������������������������������������������������������������������������������ 1


Section 1.1: Interfaces in Java������������������������������������������������������������������������������������������������������ 1
Section 1.2: Enhancements to Interfaces in Java 8 and Java 9���������������������������������������������������� 2
Section 1.3: Functional Interfaces Defined����������������������������������������������������������������������������������� 5
Section 1.4: Implementing Functional Interfaces with Pre-Java 8 Constructs����������������������������� 6
Section 1.5: Providing Default Methods in Functional Interfaces������������������������������������������������ 8
Section 1.6: Providing Static Methods in Functional Interfaces�������������������������������������������������� 11
Section 1.7: Generic Functional Interfaces��������������������������������������������������������������������������������� 13
Section 1.7.1: Generic Functional Interfaces with Type Restrictions������������������������������������� 14
Section 1.8: Specializing a Generic Functional Interface������������������������������������������������������������ 17
PROJECT 1: Playful Pets�������������������������������������������������������������������������������������������������������������� 20
Problem Statement���������������������������������������������������������������������������������������������������������������� 20
Solution��������������������������������������������������������������������������������������������������������������������������������� 20
Short Problems��������������������������������������������������������������������������������������������������������������������������� 25
Long Problems���������������������������������������������������������������������������������������������������������������������������� 26

Chapter 2: Lambda Expressions����������������������������������������������������������������������������� 29


Section 2.1: Lambda Expressions Defined���������������������������������������������������������������������������������� 29
Section 2.2: Using Lambda Expressions to Represent Functional Interfaces���������������������������� 29
Section 2.3: The Scope of a Lambda Expression������������������������������������������������������������������������ 31
Section 2.4: Lambda Argument List Variations��������������������������������������������������������������������������� 32
Section 2.5: Lambda Bodies in Block Form�������������������������������������������������������������������������������� 34

iii
Table of Contents

Section 2.6: Limitations of Lambda Expressions������������������������������������������������������������������������ 37


PROJECT 2: Compute Square������������������������������������������������������������������������������������������������������ 40
Problem Statement���������������������������������������������������������������������������������������������������������������� 40
Solution��������������������������������������������������������������������������������������������������������������������������������� 40
Short Problems��������������������������������������������������������������������������������������������������������������������������� 43
Long Problems���������������������������������������������������������������������������������������������������������������������������� 43

Chapter 3: Predicates��������������������������������������������������������������������������������������������� 45
Section 3.1: The java.util.function Package�������������������������������������������������������������������������������� 45
Section 3.2: The Predicate Interface������������������������������������������������������������������������������������������� 45
Section 3.3: Passing a Predicate to a Method����������������������������������������������������������������������������� 47
Section 3.4: Chains of Functional Interfaces������������������������������������������������������������������������������� 50
Section 3.5: Predicate Chaining Creates Complex Logical Expressions������������������������������������� 50
Section 3.5.1: Chains Involving the OR Operation����������������������������������������������������������������� 50
Section 3.5.2: Chains Involving the AND Operation��������������������������������������������������������������� 52
Section 3.5.3: Chains Involving the ! Operation��������������������������������������������������������������������� 53
Section 3.5.4: Using Predicate.isEqual���������������������������������������������������������������������������������� 54
Section 3.5.5: Using Predicate.not [JAVA 11]������������������������������������������������������������������������ 55
Section 3.6: Overriding Predicate Default Methods�������������������������������������������������������������������� 56
Section 3.7: Specializations of Predicates���������������������������������������������������������������������������������� 57
Section 3.8: Binary Predicates���������������������������������������������������������������������������������������������������� 59
PROJECT 3: Discount Dave���������������������������������������������������������������������������������������������������������� 59
Problem Statement���������������������������������������������������������������������������������������������������������������� 59
Solution��������������������������������������������������������������������������������������������������������������������������������� 60
Short Problems��������������������������������������������������������������������������������������������������������������������������� 67
Long Problems���������������������������������������������������������������������������������������������������������������������������� 67

Chapter 4: Functions���������������������������������������������������������������������������������������������� 69
Section 4.1: The Function Interface�������������������������������������������������������������������������������������������� 69
Section 4.2: Passing a Generic Function to a Method����������������������������������������������������������������� 70
Section 4.2.1: Passing a Function with Restricted or Known Type Parameters�������������������� 71

iv
Table of Contents

Section 4.3: Function Chaining��������������������������������������������������������������������������������������������������� 73


Section 4.3.1: Chains Involving the andThen Method������������������������������������������������������������ 73
Section 4.3.2: Chains Involving the compose Method����������������������������������������������������������� 73
Section 4.4: The Function.identity Method���������������������������������������������������������������������������������� 74
Section 4.5: Specializations of Functions Which Convert from Primitive Types�������������������������� 75
Section 4.6: Specializations of Functions Which Convert to Primitive Types������������������������������ 76
Section 4.7: Non-generic Specializations of Functions��������������������������������������������������������������� 77
Section 4.8: Binary Functions����������������������������������������������������������������������������������������������������� 77
Section 4.9: Creating Chains Using BiFunctions������������������������������������������������������������������������� 78
Section 4.10: Specializations of BiFunctions Which Convert to Primitive Types������������������������� 79
PROJECT 4: Sales Promotions����������������������������������������������������������������������������������������������������� 80
Problem Statement���������������������������������������������������������������������������������������������������������������� 80
Solution��������������������������������������������������������������������������������������������������������������������������������� 80
Short Problems��������������������������������������������������������������������������������������������������������������������������� 92
Long Problems���������������������������������������������������������������������������������������������������������������������������� 93

Chapter 5: Operators���������������������������������������������������������������������������������������������� 95
Section 5.1: The UnaryOperator Interface����������������������������������������������������������������������������������� 95
Section 5.2: Specializations of UnaryOperator���������������������������������������������������������������������������� 96
Section 5.2.1: Chains Involving UnaryOperator Specializations�������������������������������������������� 97
Section 5.3: The BinaryOperator Interface���������������������������������������������������������������������������������� 98
Section 5.4: Non-generic Specializations of BinaryOperator����������������������������������������������������� 99
PROJECT 5: Calculator�������������������������������������������������������������������������������������������������������������� 100
Problem Statement�������������������������������������������������������������������������������������������������������������� 100
Solution������������������������������������������������������������������������������������������������������������������������������� 100
Short Problems������������������������������������������������������������������������������������������������������������������������� 106
Long Problems�������������������������������������������������������������������������������������������������������������������������� 107

Chapter 6: Consumers������������������������������������������������������������������������������������������ 109


Section 6.1: The Consumer Interface���������������������������������������������������������������������������������������� 109
Section 6.2: Using Chains of Consumers to Compute Equations���������������������������������������������� 110

v
Table of Contents

Section 6.3: Using Consumers with println as the Terminal Operation������������������������������������� 112
Section 6.4: Non-generic Specializations of Consumers���������������������������������������������������������� 112
Section 6.5: The BiConsumer Interface������������������������������������������������������������������������������������� 114
Section 6.6: Specializations of BiConsumer������������������������������������������������������������������������������ 115
PROJECT 6: Bank Transactions������������������������������������������������������������������������������������������������� 116
Problem Statement�������������������������������������������������������������������������������������������������������������� 116
Solution������������������������������������������������������������������������������������������������������������������������������� 117
Short Problems������������������������������������������������������������������������������������������������������������������������� 128
Long Problems�������������������������������������������������������������������������������������������������������������������������� 129

Chapter 7: Suppliers��������������������������������������������������������������������������������������������� 131


Section 7.1: The Supplier Interface������������������������������������������������������������������������������������������� 131
Section 7.2: Wrapping User Prompts in a Supplier������������������������������������������������������������������� 133
Section 7.3: Non-generic Specializations of Suppliers������������������������������������������������������������� 135
PROJECT 7: Ticketing System��������������������������������������������������������������������������������������������������� 136
Problem Statement�������������������������������������������������������������������������������������������������������������� 136
Solution������������������������������������������������������������������������������������������������������������������������������� 137
Short Problems������������������������������������������������������������������������������������������������������������������������� 148
Long Problems�������������������������������������������������������������������������������������������������������������������������� 149

Chapter 8: Use in Traversing Objects�������������������������������������������������������������������� 151


Section 8.1: Traversing Objects Using Iterators������������������������������������������������������������������������ 151
Section 8.2: Traversing Java Arrays of Primitive Types������������������������������������������������������������� 152
Section 8.2.1: Using Specializations of PrimitiveIterator����������������������������������������������������� 156
Section 8.3: Traversing Objects Using Spliterators������������������������������������������������������������������� 160
Section 8.4: Traversing Iterable Objects������������������������������������������������������������������������������������ 164
Section 8.5: Traversing Iterable Objects That Contain Java Arrays of Primitives���������������������� 165
Section 8.5.1: Using Specializations of PrimitiveIterator����������������������������������������������������� 169
Section 8.6: Traversing Maps���������������������������������������������������������������������������������������������������� 171
Section 8.7: Traversing Sets������������������������������������������������������������������������������������������������������ 172
PROJECT 8: Payroll�������������������������������������������������������������������������������������������������������������������� 172

vi
Table of Contents

Problem Statement�������������������������������������������������������������������������������������������������������������� 172


Solution������������������������������������������������������������������������������������������������������������������������������� 173
Short Problems������������������������������������������������������������������������������������������������������������������������� 179
Long Problems�������������������������������������������������������������������������������������������������������������������������� 180

Chapter 9: Use in Collections�������������������������������������������������������������������������������� 181


Section 9.1: Removing Elements from a Collection������������������������������������������������������������������ 181
Section 9.2: Populating an Array����������������������������������������������������������������������������������������������� 182
Section 9.3: Replacing the Elements of a List or a Map������������������������������������������������������������ 184
Section 9.4: Parallel Computations on Arrays��������������������������������������������������������������������������� 185
Section 9.5: Map Computations������������������������������������������������������������������������������������������������ 186
Section 9.6: Map Merging��������������������������������������������������������������������������������������������������������� 189
Section 9.7: Functional Interfaces and Sets������������������������������������������������������������������������������ 191
PROJECT 9: Department of Motor Vehicles������������������������������������������������������������������������������� 191
Problem Statement�������������������������������������������������������������������������������������������������������������� 191
Solution������������������������������������������������������������������������������������������������������������������������������� 192
Short Problems������������������������������������������������������������������������������������������������������������������������� 204
Long Problems�������������������������������������������������������������������������������������������������������������������������� 206

Chapter 10: Use in Comparing Objects����������������������������������������������������������������� 209


Section 10.1: The Comparator Interface����������������������������������������������������������������������������������� 209
Section 10.2: Some Useful Comparator Methods��������������������������������������������������������������������� 211
Section 10.3: The Comparator comparing Methods������������������������������������������������������������������ 212
Section 10.4: Specializations of the Comparator comparing Method��������������������������������������� 217
Section 10.5: Building Chains of Comparators�������������������������������������������������������������������������� 218
Section 10.6: Specializing Comparator Chain Components������������������������������������������������������ 221
Section 10.7: Using Comparators to Sort Lists�������������������������������������������������������������������������� 222
Section 10.8: Using Comparators to Sort Java Arrays��������������������������������������������������������������� 224
Section 10.9: Using Comparators to Organize Maps����������������������������������������������������������������� 227
Section 10.10: Using Comparators in BinaryOperator Methods������������������������������������������������ 228
PROJECT 10: Real Estate Broker����������������������������������������������������������������������������������������������� 229

vii
Table of Contents

Problem Statement�������������������������������������������������������������������������������������������������������������� 229


Solution������������������������������������������������������������������������������������������������������������������������������� 230
Short Problems������������������������������������������������������������������������������������������������������������������������� 239
Long Problems�������������������������������������������������������������������������������������������������������������������������� 240

Chapter 11: Use in Optionals�������������������������������������������������������������������������������� 243


Section 11.1: Creating an Optional�������������������������������������������������������������������������������������������� 243
Section 11.2: Determining If an Optional Is Present����������������������������������������������������������������� 244
Section 11.3: Retrieving the Contents of an Optional��������������������������������������������������������������� 245
Section 11.4: Creating Chains of Optionals������������������������������������������������������������������������������� 246
Section 11.5: Printing the Contents of an Optional������������������������������������������������������������������� 248
Section 11.6: Filtering Optionals����������������������������������������������������������������������������������������������� 249
Section 11.7: Optional Chains Involving map and flatmap�������������������������������������������������������� 250
PROJECT 11: Guess a Number�������������������������������������������������������������������������������������������������� 253
Problem Statement�������������������������������������������������������������������������������������������������������������� 253
Solution������������������������������������������������������������������������������������������������������������������������������� 253
Short Problems������������������������������������������������������������������������������������������������������������������������� 256
Long Problems�������������������������������������������������������������������������������������������������������������������������� 257

Chapter 12: Use in Streams���������������������������������������������������������������������������������� 259


Section 12.1: Generating Stream Elements������������������������������������������������������������������������������ 259
Section 12.2: Traversing Streams��������������������������������������������������������������������������������������������� 260
Section 12.3: Filtering Stream Elements����������������������������������������������������������������������������������� 261
Section 12.4: Converting an Object to a Stream����������������������������������������������������������������������� 262
Section 12.5: Sorting Stream Elements������������������������������������������������������������������������������������ 262
Section 12.6: Selecting the Smallest or Largest Element in a Stream�������������������������������������� 263
Section 12.7: flatMap vs. map�������������������������������������������������������������������������������������������������� 264
Section 12.8: Reducing Stream Elements��������������������������������������������������������������������������������� 266
Section 12.9: Collecting Stream Elements into a Mutable Reduction��������������������������������������� 267
Section 12.9.1: Using Prewritten Collectors������������������������������������������������������������������������ 271
Section 12.10: Building Streams Interactively�������������������������������������������������������������������������� 276

viii
Table of Contents

Section 12.11: Displaying Intermediate Results����������������������������������������������������������������������� 277


Section 12.12: Stream Specializations������������������������������������������������������������������������������������� 278
PROJECT 12: Dave’s Part Inventory������������������������������������������������������������������������������������������� 279
Problem Statement�������������������������������������������������������������������������������������������������������������� 279
Solution������������������������������������������������������������������������������������������������������������������������������� 279
Short Problems������������������������������������������������������������������������������������������������������������������������� 290
Long Problems�������������������������������������������������������������������������������������������������������������������������� 290

Chapter 13: Use in Multithreaded Programs�������������������������������������������������������� 293


Section 13.1: Performing Computations Using Runnable and Callable������������������������������������� 293
Section 13.1.1: Using Runnable in Optionals����������������������������������������������������������������������� 297
Section 13.2: Futures and FutureTasks������������������������������������������������������������������������������������� 297
Section 13.3: CompletionStages and CompletableFutures������������������������������������������������������ 298
Section 13.4: Creating CompletableFutures and Retrieving Their Results�������������������������������� 299
Section 13.5: Using the thenApply and thenAccept Methods��������������������������������������������������� 301
Section 13.6: Processing the First Asynchronous Future to Complete������������������������������������� 302
Section 13.7: Making a Future Dependent on Another Future�������������������������������������������������� 303
Section 13.8: Cancelling a Future��������������������������������������������������������������������������������������������� 304
Section 13.9: When Futures Throw Unchecked Exceptions������������������������������������������������������ 306
Section 13.10: Running Futures in Parallel������������������������������������������������������������������������������� 307
PROJECT 13: Sentence Builder������������������������������������������������������������������������������������������������� 313
Problem Statement�������������������������������������������������������������������������������������������������������������� 313
Solution������������������������������������������������������������������������������������������������������������������������������� 313
Short Problems������������������������������������������������������������������������������������������������������������������������� 326
Long Problems�������������������������������������������������������������������������������������������������������������������������� 327

Chapter 14: Use in Atomic Calculations��������������������������������������������������������������� 329


Section 14.1: Atomic Integers��������������������������������������������������������������������������������������������������� 330
Section 14.1.1: Accumulating an Atomic Value������������������������������������������������������������������� 332
Section 14.1.2: Updating an Atomic Value��������������������������������������������������������������������������� 333
Section 14.1.3: Comparing an Atomic Value������������������������������������������������������������������������ 334

ix
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Table of Contents

Section 14.2: Atomic Longs������������������������������������������������������������������������������������������������������� 337


Section 14.3: Atomic Booleans������������������������������������������������������������������������������������������������� 338
Section 14.4: Atomic Arrays������������������������������������������������������������������������������������������������������ 338
Section 14.5: Atomic References���������������������������������������������������������������������������������������������� 339
PROJECT 14: Bank Account������������������������������������������������������������������������������������������������������� 341
Problem Statement�������������������������������������������������������������������������������������������������������������� 341
Solution������������������������������������������������������������������������������������������������������������������������������� 341
Short Problems������������������������������������������������������������������������������������������������������������������������� 345
Long Problems�������������������������������������������������������������������������������������������������������������������������� 346

Chapter 15: Use in JavaFX Applications��������������������������������������������������������������� 347


Section 15.1: Handling JavaFX Events�������������������������������������������������������������������������������������� 347
Section 15.2: Building JavaFX UI Components�������������������������������������������������������������������������� 349
Section 15.3: JavaFX Builder Factories������������������������������������������������������������������������������������� 352
Section 15.4: Monitoring Changes in Collections���������������������������������������������������������������������� 356
Section 15.4.1: Monitoring List Changes����������������������������������������������������������������������������� 356
Section 15.4.2: Monitoring Set Changes����������������������������������������������������������������������������� 362
Section 15.4.3: Monitoring Map Changes���������������������������������������������������������������������������� 366
Section 15.5: Invalidating an Observable Object����������������������������������������������������������������������� 370
PROJECT 15: DMV GUI��������������������������������������������������������������������������������������������������������������� 374
Problem Statement�������������������������������������������������������������������������������������������������������������� 374
Solution������������������������������������������������������������������������������������������������������������������������������� 374
Short Problems������������������������������������������������������������������������������������������������������������������������� 388
Long Problems�������������������������������������������������������������������������������������������������������������������������� 389

Appendix: Method References������������������������������������������������������������������������������ 391


Section A.1: Using References to Static Methods to Represent Functional Interfaces������������� 391
Section A.2: References to Instance Methods��������������������������������������������������������������������������� 393
Section A.3: References to Constructors����������������������������������������������������������������������������������� 394
Section A.4: Passing Method References as Arguments����������������������������������������������������������� 395

x
Table of Contents

Section A.5: Representing Functions with Method References������������������������������������������������ 397


Section A.6: Using Method References with Comparators�������������������������������������������������������� 399
Section A.7: Using Method References with Streams��������������������������������������������������������������� 400

Index��������������������������������������������������������������������������������������������������������������������� 405

xi
About the Author
Ralph Lecessi is a software engineer with over 30 years’
professional programming experience in the aerospace,
telecommunications, and payment industries at companies
including Lockheed Martin, Alcatel-Lucent, AT&T, and
Northrop Grumman. He is currently lead embedded
software developer at TranSendIT, Inc in Mount Laurel,
New Jersey.
Ralph is also the author of JAVATM - The Beginnings—a
text on basic Java programming that includes many examples and diagrams.
Ralph is an adjunct professor of programming at Middlesex County College, where
he teaches basic and object-oriented programming in Java. He lives in South Brunswick,
New Jersey, with his wife and two children.

xiii
About the Technical Reviewer
Manuel Jordan Elera is an autodidactic developer and
researcher who enjoys learning new technologies for his
own experiments and creating new integrations. Manuel
won the 2010 Springy Award Community Champion and
Spring Champion 2013. In his little free time, he reads
the Bible and composes music on his guitar. Manuel is
known as dr_pompeii. He has tech-reviewed numerous
books for Apress, including Pro Spring, Fourth Edition
(2014); Practical Spring LDAP (2013); Pro JPA 2, Second
Edition (2013); and Pro Spring Security (2013). Read his
13 detailed tutorials about many Spring technologies, contact him through his blog at
www.manueljordanelera.blogspot.com, and follow him on his Twitter account,
­@dr_pompeii.

xv
Foreword
Functional Interfaces in Java shows how to organize and simplify Java programs through
the use of functional interfaces.
Chapters 1 and 2 introduce functional interfaces and discuss their implementation
using lambda expressions.
Chapters 3 through 7 discuss the functional interfaces present in the java.util.
function package.
Chapters 8 through 15 show how to use functional interfaces to perform various
programming tasks.
The appendix discusses method references and how they can be used in the
implementation of functional interfaces.
The text presents each topic with detailed descriptions and many examples. Each
chapter also contains a project through which I will guide you step by step to the
solution. Each chapter also contains short homework problems which reinforce the
subject matter and longer assignments which utilize the current topic to solve a real-­
world problem.
Knowledge of basic Java programming is needed to understand the examples in this
text. If you need a primer on basic Java, I recommend JAVATM- The Beginnings.
Here are some notes regarding the programming style used in this book:

1) The rules of encapsulation have been relaxed (most class fields


have been given package access) to make the examples easier to
read.

2) Method references are not used in the chapter portion of this


text. Lambda expressions have been used instead to present
a consistent implementation of functional interfaces. Method
references are discussed in the appendix.

All examples have been tested in Java 9, Java 10, and Java 11 unless otherwise noted.
I hope you enjoy reading Functional Interfaces in Java as much as I have enjoyed
writing it.
—Ralph Lecessi

xvii
CHAPTER 1

Functional Interfaces
Section 1.1: Interfaces in Java
In Java, an interface specifies one or more methods. The interface is a contract which
must be honored by all implementing classes. The interface defined in Listing 1-1
specifies methods method1 and method2.

Listing 1-1. I1.java

interface I1
{
    void method1();
    String method2(String x);
}

Any class that implements an interface must provide implementations for all the
methods declared in the interface (or the class must be declared as abstract). Since the
class defined in Listing 1-2 provides implementations for both method1 and method2,
objects of class C1 can be instantiated.

Listing 1-2. C1.java

class C1 implements I1
{
    @Override
    public void method1() {}
    @Override
    public String method2(String x) { return x; }
}

1
© Ralph Lecessi 2019
R. Lecessi, Functional Interfaces in Java, https://doi.org/10.1007/978-1-4842-4278-0_1
Chapter 1 Functional Interfaces

 ection 1.2: Enhancements to Interfaces in Java 8


S
and Java 9
In Java 8, interfaces were allowed to have static and default methods. A static method
has a single instance associated with the interface. A static method can be called without
creation of an object. A default method is an implementation provided by the interface
that does not have to be overridden by an implementing class. Default methods help in
the compilation of legacy code.
The program in Listing 1-3 defines interface I2 that declares field s which contains
the string “I2”. If a constant is common to all classes which implement an interface, it
should be defined as a field in the interface. The interface also defines a static and a
default method.
Since method1 is static, it can be called directly from interface I2, without creating an
object. When called, it prints “I2”, which is the value of field s. Since class C2 overrides
method2, the call to method2 from objC2 executes the C2 implementation, which returns
the string argument and prints “Hello”. Since class C3 does not override method2, the call
to method2 from objC3 executes the default implementation provided in interface I2,
which concatenates the string argument to field s and prints “I2World”.

Listing 1-3. I2.java

interface I2
{
    String s = "I2";
    static void method1()
    {
        System.out.println(s);
    }

    default String method2(String x)


    {
        return s + x;
    }
}

2
Chapter 1 Functional Interfaces

class C2 implements I2
{
    @Override
    public String method2(String x) { return x; }
}

class C3 implements I2 {}

class TestI2
{
    public static void main(String[] args)
    {
        I2.method1();
        I2 objC2 = new C2();
        I2 objC3 = new C3();
        System.out.println(objC2.method2("Hello"));
        System.out.println(objC3.method2("World"));
    }
}

PROGRAM OUTPUT:

I2
Hello
I2World

In Java 9, interfaces were allowed to have private methods. Private methods are
useful to call from default methods. The program in Listing 1-4 concatenates a random
integer between 0 and 99 to the string “Hello”. Interface I3 contains private method
getNumber which generates the integer. This method is called by default method M1.

Listing 1-4. I3.java

import java.util.Random;
interface I3
{
    private int getNumber() { return (new Random()).nextInt(100); }
    default String M1(String s)

3
Chapter 1 Functional Interfaces

    {
        return s + getNumber();
    }
}

class C4 implements I3
{
}

class TestI3
{
    public static void main(String[] args)
    {
        I3 objC4 = new C4();
        System.out.println(objC4.M1("Hello"));
    }
}

PROGRAM OUTPUT:

Hello21

In Java 9, interfaces can also have private static methods. Since the static methods of
an interface can be called without creation of an implementing object, these methods
can only be called by public static methods defined in the interface.
Interface I4 in the following program defines public static method getName which
calls private static method getPrefix to add the prefix “Mr. ” or “Ms. ” based on gender.
The getName method can be called from the main method of class TestI4. The getPrefix
method can be called only from inside method getName.

Listing 1-5. I4.java

interface I4
{
    private static String getPrefix(String p)
    {
        return p.equals("male")? "Mr. " : "Ms. ";
    }
    public static String getName(String n, String p)

4
Chapter 1 Functional Interfaces

    {
        return getPrefix(p) + n;
    }
}

class TestI4
{
    public static void main(String[] args)
    {
        System.out.println(I4.getName("Smith", "female"));
        System.out.println(I4.getName("Jones", "male"));
    }
}

PROGRAM OUTPUT:

Ms. Smith
Mr. Jones

Section 1.3: Functional Interfaces Defined


A functional interface is an interface with a single abstract method, called its functional
method. The code in Listing 1-6 defines functional interface StringProcessor, which
specifies functional method process that takes a string argument and returns a string.
The @FunctionalInterface annotation instructs the compiler to verify that the interface
has only one abstract method.

Listing 1-6. StringProcessor.java


@FunctionalInterface
interface StringProcessor
{
       String process(String x);
}

If StringProcessor contained more than one abstract method, the


@FunctionalInterface annotation would cause a compilation error to be generated.
The code in Listing 1-7 demonstrates.

5
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Chapter 1 Functional Interfaces

Listing 1-7. StringProcessor.java (Incorrect)

@FunctionalInterface    ERROR: Not a functional interface.


                               Contains more than one abstract
                               method.
interface StringProcessor
{
       String process(String x);
       String process2(String x);
}

Functional interfaces are ideal for defining a single problem or operation. In Java 8,
the API was enhanced to utilize functional interfaces. Many of the functional interfaces
can contain static and default methods, making them extendable by the user.

 ection 1.4: Implementing Functional Interfaces


S
with Pre-Java 8 Constructs
A functional interface can be implemented by defining a named class that provides
the functional method. The class in Listing 1-8 implements functional interface
StringProcessor by providing an implementation of functional method process.

Listing 1-8. NamedStringProcessor.java

class NamedStringProcessor implements StringProcessor


{
    @Override
    public String process(String s) { return s; }
}

A functional interface can also be implemented by an anonymous class that provides


the functional method. The following code defines an anonymous class that implements
StringProcessor. The anonymous implementation is referenced by variable anonSP.

6
Chapter 1 Functional Interfaces

StringProcessor anonSP = new StringProcessor() {


    @Override
    public String process(String x)
    {
        return x.toUpperCase();
    }
};

The program in Listing 1-9 provides both named class and anonymous class
implementations for functional interface StringProcessor.

Listing 1-9. TestStringProcessor.java

public class TestStringProcessor


{
    public static void main(String[] args)
    {
        NamedStringProcessor namedSP = new NamedStringProcessor();

        StringProcessor anonSP = new StringProcessor() {


            @Override
            public String process(String x)
            {
                return x.toUpperCase();
            }
        };
        System.out.println(namedSP.process("hello"));
        System.out.println(anonSP.process("hello"));
    }
}

PROGRAM OUTPUT:

Hello
HELLO

7
Chapter 1 Functional Interfaces

 ection 1.5: Providing Default Methods in


S
Functional Interfaces
A functional interface can provide default methods. An implementing class can use the
default methods or provide its own versions.
Suppose a program needs to print different receipts based on item, price, discount,
and tax. Listing 1-10 defines the Receipt class that contains the corresponding fields.

Listing 1-10. Receipt.java

class Receipt
{
    String item;
    double price;
    double discount;
    double tax;
    public Receipt(String i, double a, double d, double s)
    {
        item     = i;
        price    = a;
        discount = d;
        tax      = s;
    }
    public Receipt(Receipt r)
    {
        item     = r.item;
        price    = r.price;
        discount = r.discount;
        tax      = r.tax;
    }
}

In order to define a framework for receipt printing, a functional interface with a


functional method that accepts a Receipt argument can be utilized. Listing 1-11 defines
functional interface ReceiptPrinter whose functional method print accepts a Receipt.
ReceiptPrinter also provides a default method that calculates the total amount based

8
Chapter 1 Functional Interfaces

on price, discount, and tax, but allows implementing classes to override the calculation.
The default method calls private method getDiscounterPrice which applies the
discount to the price.

Listing 1-11. ReceiptPrinter.java

@FunctionalInterface
interface ReceiptPrinter
{
    void print(Receipt receipt);

    private double getDiscountedPrice(Receipt receipt)


    {
        return receipt.price
            - (receipt.price * receipt.discount);
    }

    default double computeTotal(Receipt receipt)


    {
        double discountedPrice = getDiscountedPrice(receipt);

        return discountedPrice + (discountedPrice * receipt.tax);


    }
}

The following ReceiptPrinter implementation prints each Receipt field on a


separate line followed by the total. It uses the default total calculation.

ReceiptPrinter simpleReceiptPrinter = new ReceiptPrinter() {


    @Override
    public void print(Receipt receipt)
    {
        System.out.println("\nItem :\t" + receipt.item);
        System.out.println("Price:\t"   + receipt.price);
        System.out.println("Disc:\t"    + receipt.discount);
        System.out.println("Tax:\t"     + receipt.tax);
        System.out.println("Total:\t"   + computeTotal(receipt));
    }
};

9
Chapter 1 Functional Interfaces

The following ReceiptPrinter implementation is for merchants who are exempt from
tax. It provides its own implementation of the total calculation which does not include tax.

ReceiptPrinter exemptReceiptPrinter = new ReceiptPrinter() {


    @Override
    public void print(Receipt receipt)
    {
        System.out.println("\nItem :\t" + receipt.item);
        System.out.println("Price:\t"   + receipt.price);
        System.out.println("Disc:\t"    + receipt.discount);
        System.out.println("Total:\t"   + computeTotal(receipt));
    }
    @Override
    public double computeTotal(Receipt receipt)
    {
        return receipt.price - (receipt.price * receipt.discount);
    }
};

The simpleReceiptPrinter and ExemptReceiptPrinter implementations can be


used to print the same receipt. The following code prints one copy of the receipt whose
total is based on tax and a second copy of the receipt whose total is not based on tax:

Receipt receipt = new Receipt("shirt", 20.00, 0.05, 0.07);


simpleReceiptPrinter.print(receipt);
exemptReceiptPrinter.print(receipt);

OUTPUT:

Item :    shirt
Amount:   20.0
Disc:     0.05
Tax:      0.07
Total:    20.33

Item :    shirt
Amount:   20.0
Disc:     0.05
Total:    19.0
10
Random documents with unrelated
content Scribd suggests to you:
Clancy was!

Raising her long lashes suddenly, she met his ardent, passionate, yet
respectful gaze.

Both pair of eyes sought the floor simultaneously; and it would have
been no easy task for one to have determined which face flushed
the deepest—the maiden’s or her lover’s; for Clancy Vere knew he
did love Vinnie Darke with all his heart.

Darke had not noticed this little by-play, and he asked, suddenly, as
the pretty air-castles both had been rearing up vanished as air
castles are wont to do when they are rudely jarred:

“How long do you think you were at the cavern before your
consciousness returned?”

“I am not quite certain—two or three hours I guess.”

“And it was Leander Maybob that rescued you?”

“Yes; but he did not himself carry me to the cave. It was more than
a mile away that he found me; and although he is very strong, he
could not lug me on his back all that distance. When consciousness
returned he told me about it. Alonphilus the dwarf conveyed me to
the cave.”

“How?” asked Darke. 75

“Oh, Leander told me all about that, too. I was brought on a horse
—”

“What color was the horse?” interrupted Vinnie.

“On a white horse!” pursued the woodman.

“Yes.”
“You were rolled up from head to foot in a heavy black cloth, were
you not?” Darke went on, eagerly.

“I do not know,” said Clancy, surprised at so many questions. “But


he carried me before him across the saddle.”

Father and daughter uttered simultaneous cries of surprise.

Another mystery was solved!


CHAPTER XII.
THE FOREST ROSE.

Ku-nan-gu-no-nah walked swiftly away with the deadly rifle of


Leander Maybob, the giant hunter, still leveled at his head, fairly
demoniac with wild and impotent rage. The workings of his dark
face were fearfully suggestive of the denizens of the bottomless pit.

Had he been armed he would not have left the vicinity without first
attempting the life of the man who had him in his power and who
held his very life at his disposal; but he was powerless, having no
weapons except a short, sharp-pointed knife which he always carried
in addition to his hunting-knife, and this would be useless, except in
a hand-to-hand conflict, which even in his wild passion he had not
the hardihood to dare.

In an hour’s time he came to the boundary of the wilderness and the


broad prairie stretched its level surface before him as far as he could
see. Not a tree or a bush was there visible in all this vast plain; only
the tall grasses, beat down and tangled by the fearful tempest that
had raged through the afternoon.

Turning from the nearly direct course he had been pursuing, 76


the chief made his way, with long, rapid strides, to the place
where, in the midst of a dense growth of bushes in the center of
which there was a little plat of smooth, grassy ground, destitute of
undergrowth, he had tethered his horse early in the afternoon. In
less time than it takes to tell it, he was mounted and galloping away
over the plain.

In a little while he struck an indistinct, scarcely worn road, or rather


broad track—one of the emigrant routes of the North-west. He
followed the track for an hour or more and then making a gradual
detour to the left, kept on at a swift rolling gallop which he never
slackened till he reached the Indian encampment, situated at the
foot of a steep, rocky hill that loomed up through the storm and
darkness, in dull relief against the leaden sky. Throwing himself
hastily from his horse, he stalked rapidly along and entered a
wigwam at the further end of the encampment. An aged Indian sat
on a roll of skins at one side of the place, in an attitude of deep grief
or despondency. He simply glanced up as the chief entered, then
dropping his face again into his hands, sitting silent and apparently
in great agony of mind.

“How is the Forest Rose to-night?” the chief asked, glancing toward
a couch of skins and blankets on the opposite side of the lodge, on
which he could see the form of a female reclining by the dim fire-
light that illuminated the wigwam. She lay silent and motionless as
though life had fled.

“The Forest Rose is very ill,” replied the old Indian, mournfully, “and
she will die! Yon-da-do, the great medicine man, has said so. He has
made use of all his ceremonies and mystic arts, but he can not save
her. The lovely Forest Rose must die!”

As he ceased speaking he arose, and lighting a small pitch-pine


torch in the fire, went over to the side of the couch. Throwing aside
the covering from her face, he allowed the light to fall upon it for a
moment. It was a beautiful face, darkly lovely—the face of an Indian
maiden in the first flush of womanhood. She was rather light for one
of her dusky race, with heavy masses of raven-black hair falling in
lovely confusion about her statuesque face, in whose contour the
hard angularity of the Indian type was not discernible, and down
upon her perfectly-shaped neck, and softly-rounded shoulders. 77
Her long, heavy lashes lay upon her cheeks, which were very
pale, hiding her dark lustrous eyes, which, when lighted up with
health, added not a little to her almost bewildering beauty. But now
the lovely Forest Rose lay like one dead.
“Let my father look up and be happy!” said the chief. “Ku-nan-gu-no-
nah has seen a medicine-woman to-day, that can surely bring back
life to the Forest Rose. The medicine-woman that I saw was a
mighty conjuror. The Great Spirit has given her greater power than
that of Yon-da-do!”

“Who is this mighty magician?”

“She is a pale-face maiden, as beautiful as the Forest Rose,” replied


the chief.

“Would she come?” asked the old Indian, while a hopeful light
flashed out of his aged eyes, undimmed by the flight of time. “Would
a white medicine-woman come to give life back to an Indian girl!”

“She would not come willingly,” said the crafty chief, “but she must
be brought! If she is not, the Forest Rose will die!”

“Then she must be brought!” said the old Indian, decisively. “I will
call a council of braves in the morning, and a party shall be sent to
bring the white magician. The Forest Rose must be saved!”

The aged Indian was the real chief of the tribe—that is, although he
was too old to go on the war-path, leaving the active fighting to the
younger and more warlike Ku-nan-gu-no-nah, he was the real
moving spirit, always planning and ordering all important
movements of the band. The languishing Forest Rose was his
daughter.

“It is well,” said Ku-nan-gu-no-nah, as he went away.

“The great medicine-woman will save the Forest Rose, and again she
will sing like the birds in the trees to gladden the heart of her father,
the great chief.”

Wild Buffalo, the aged sachem, called a council of braves early in the
morning, and at midday, the subtle Ku-nan-gu-no-nah, at the head
of a dozen picked warriors, was riding over the prairie in quest of
“Sun-Hair,” the beautiful magician.

78
CHAPTER XIII.
THE FACE AT THE WINDOW.

“So the mystery of the disappearing horseman is explained very


satisfactorily at last, Vinnie,” said Darke, after their surprise had
subsided somewhat.

“Yes,” she replied, “all but the mystery of his disappearance.”

“True,” said her father; “we are still in the dark concerning that. How
could it have been accomplished?”

“I know not. It vanished before my very eyes!”

“It was doubtless owing to some peculiar turn of the path he was
following, or something of that sort,” reasoned the woodman. “A
very sudden turn among the dense growth of shrubbery that is so
thick about the place might have concealed the white horse and his
rider from view almost instantly.”

“I think very likely it was owing to that or a similar cause,” returned


Vinnie. “I suppose we shall have to accept that explanation till a
better one presents itself. It is strange that I should have allowed
myself to be alarmed at so trivial a matter. I do not think I am
superstitious. But that limp, helpless-looking black thing did appear
ghastly through the storm!”

It will be remembered that Clancy had not heard of Vinnie’s


adventures and perils of the day before; and he did not understand
the conversation that the others had kept up for the past few
minutes. Noting the questioning look on his face, the woodman said:

“There is still another story of peril and escape that you are yet to
hear. I believe I will take a short bout in the forest in search of a
turkey; and if I am successful we’ll have a supper fit for the
President. Vinnie can tell you the story while I am gone. Be sure you
don’t leave out any of the important points, and don’t forget to
mention your lover’s visit yesterday. A truthful account of the
shocking manner in which you treated him ought to be a 79
caution to sparks! If I was a young fellow, now—”

“There now! stop!” said Vinnie, with a vivid blush. “I think you’re
really too bad! And besides, you are not fit to go out to-day, after
your hurt, and—”

“That will do,” interrupted Darke, banteringly, examining the lock of


his rifle the while. “I am well enough for any thing now, and I mean
to take just this one more hunt while I’ve an opportunity. I dare not
leave you here any more alone, you know, and I’m going while I’ve
got Clancy here to keep guard over you! So good-by, and don’t think
of my coming back for two hours at the very soonest!”

She went up to him for her customary kiss.

“There,” said he, as he bent and pressed his lips to hers. “Good-by,
little one. And, Clancy, I want you to see that no one repeats this
operation during my absence. She’s all I’ve got, and I leave her in
your care. Don’t forget the story, Vinnie!” And a moment later he
passed out, closely followed by the blood-hound. Vinnie seized hold
of one of the great brute’s long ears, and bending low over him, to
hide her flushed face from Clancy’s view, said, playfully:

“There, Death, don’t run away from him as you did from me
yesterday!”

Then, while the young hunter thought she was putting herself to a
great deal of useless trouble, considering that the room was very
warm already, she went and busied herself at the hearth, for what
seemed to him a very long time, stirring the fire and putting on more
wood.
“What story does your father mean?” he asked, when she had at last
finished. “I thought from what you said that you saw the dwarf
when he was carrying me to the cave. It can not be that you were
out in that terrible storm?”

“But I was,” said Vinnie, with a smile, “and I half think I was the
victim of almost as serious a series of accidents as yourself. Papa
told me to tell you the story, and I suppose I must obey. Are you
sure it will be of interest to you?”

“Yes,” he replied, eagerly. “I know it will be of interest to me. Tell it,


please.”

And, half shyly at first, Vinnie complied with his request. He


interrupted her many times during her recital, with exclamations of
surprise and wonder; and when she had finished, and sat 80
demurely before him, with her little hands folded in her lap,
and her lovely face sober and thoughtful, he said:

“Heaven be praised for your deliverance! What if you had not


escaped?”

“Why, then, I suppose—” she began, surprised at his excited


manner. But he cut short what she would have said, by saying,
vehemently:

“If you had not, I would not now account my life worth as much as a
burnt charge of powder!”

Vinnie glanced up at him quickly, but her long lashes drooped as she
met his ardent look.

He arose to his feet, and standing up before her, went on in rapid,


eager tones:

“I love you, Vinnie Darke, as I can never love another woman in the
whole world! I ask for your love in return. Can you—will you give it
to me, Vinnie darling?”

She sat silent a moment—a moment that seemed interminable to


the anxious young hunter—with flushed face and downcast eyes.
The next, she was clasped in his strong arms, and he pressed a
tender kiss on her brow, as he said, in a low voice:

“Do you love me, Vinnie?”

The lovely, golden-brown head bent down until it was pillowed on


his bosom, the red, full lips were pressed half timidly to his, the
deep, loving blue eyes looked trustfully up into his own, and Clancy
knew that she was his till death!

“My own darling Vinnie!” said he, proudly.

“Yes,” she whispered, “yours always!”

I am afraid if the woodman could have seen the little episode that
was taking place in the cabin then, he would have thought Clancy
just the least bit forgetful of the injunction he had put upon him
when he went away—of course he would not willfully ignore it!

There was a slight, almost imperceptible sound outside the cabin,


that escaped the young hunter’s usually quick ear, and a dark face
was pressed for an instant against one of the lower panes of the
little window at the side of the door. It was withdrawn almost as
soon as it appeared.

“And you will be my wife, Vinnie—mine to love and cherish 81


always?” Clancy went on.

“Yes.”

“And your father? What will he say?”


“I do not think he will oppose us very strongly,” she said,
remembering his words to her that afternoon.

“We will ask him and see, when he comes back.”

Again that dark face peered into the room a moment and then
vanished as it had done before.

But so engrossed were they with each other—their minds so filled


with their new-found happiness—that they had no time to think of
any thing else.

“How hard I shall try to be worthy of your priceless love, and to


make your life happy!” said the young hunter, as she released herself
from his embrace. As she stood up, her eyes were turned toward the
window.

The face was flattened against the glass again!

“Merciful Heaven!” she cried, “there is Ku-nan-gu-no-nah! Oh,


Clancy, save me!”
CHAPTER XIV.
VINNIE A PRISONER.

Darke had been gone but a little while from the cabin, before he was
startled by the report of fire-arms, and the shrill war-whoop of the
band of Indians who, under the leadership of the wily Ku-nan-gu-no-
nah, had been sent out to capture Vinnie and bring her to the relief
of the suffering Forest Rose, who, although they knew it not, was
dead, having dropped quietly and peacefully away soon after they
left the encampment.

These sounds came from the direction of the cabin, and by a kind of
intuitive perception, he knew in an instant what was taking place
there.

He had just discharged his rifle at a fine turkey that the blood-hound
had come upon in a dense thicket; and reloading it as he ran, he
dashed with his utmost speed through the tangled 82
undergrowth and over fallen trees and heaps of half-decayed
brushwood back toward the scene of the conflict, which still
continued, as the sharp, oft-repeated reports of guns and the
appalling screeches of the Indians attested.

The terrible suspense and agony of mind that he suffered in the few
minutes that passed before he reached the edge of the clearing, it
would be impossible to depict. He knew that the young hunter was
as brave as a lion, and would not give up while life lasted; but he
judged from the steady and rapid fire kept up by the savages that
the odds against him were fearful.

“My God!” he gasped, as he bounded forward, holding his long rifle


ready for use at an instant’s warning, “the bloody fiends will butcher
them both! If I could only be there to help them!”
Suddenly, as he ceased speaking, the firing, which for two or three
minutes past had been almost incessant, stopped. There was a
moment of awful silence to the listening woodman, then there came
a loud crash.

Darke knew what this was.

“Heavens!” he cried, “the devils have forced the door! Nothing can
save them now! Their doom is sealed! Oh, Vinnie! Vinnie!”

His agony was terrible.

He had reached the boundary of the clearing. It was rapidly growing


dark now, and he had little fear of discovery. He paused a moment
to reconnoiter. Only two Indians were visible outside the cabin. He
raised his rifle to his face; his aim was quick and sure; and an
instant later one of the savages threw up his arms, and with an ear-
splitting screech of agony, fell on his face, dead.

Almost simultaneously with the report of the woodman’s trusty


weapon, another rung out inside the cabin.

“It is Vinnie’s revolver!” muttered Darke as he stepped quickly out of


sight behind a clump of bushes and proceeded to reload. “Thank
God she yet lives!”

Peering out, he discovered that the remaining Indian had set fire to
the cabin and was skulking around the other side, probably to get
out of range of his unerring rifle.

It was nearly dark now, but the settler fired again, and a bullet 83
went crashing through the savage’s brain, just as he had
almost gained the coveted shelter.

Vinnie’s revolver cracked again inside the cabin as Darke rammed


home another load; and he uttered another fervent “Thank God!” as
he thought that she had been saved thus far. At his request, she had
placed it upon her person that morning, and he had reason to think
that it was being fired by her own hands. He could not distinguish
the sound of Clancy’s weapon from the Indians’; but he knew him
well enough to be certain that he would not yield except with his
life.

The fire was creeping up the side of the cabin, gaining ground
rapidly in the dry timber of which it was constructed. In a few
moments the whole building would be in a light blaze. An attempt to
extinguish the flames would, Darke saw, be fruitless.

There was no one to oppose his advance across the clearing since
he had slain the two savages left on the outside to fire the cabin and
guard against a surprise by any one from without, and closely
followed by Death, he dashed over the intervening space to the
open door of the cabin.

Looking within he saw, by the light of the fire blazing on the hearth,
that Clancy Vere was engaged in a desperate, hand-to-hand struggle
with three Indians. His back was against the wall, and with an
almost superhuman effort he forced them back and kept them at
bay with his clubbed rifle. Their guns were not loaded; but the
young hunter detected one of the trio in the act of charging his rifle,
while the two others vainly tried to get at him with their knives, and,
quickly whipping out his six-shooter, one chamber of which held a
leaden bullet that soon proved a quietus to this most dangerous of
his assailants, he discharged it and had only two enemies to contend
with.

The next moment the young hunter’s clubbed weapon fell with
deadly force upon the head of one of the Indians, crushing it like an
egg-shell, while at the same instant the other fell, pierced through
the brain by a ball from Darke’s unerring rifle.

Clancy had fought like a tiger, and though he had not been
dangerously wounded, he had not escaped unscathed. A bullet 84
fired through the window, before the Indians had forced an entrance
through the battered-down door of the cabin, had grazed his temple,
making an ugly though not dangerous furrow, and carrying away a
portion of his ear. The blood was trickling down his face, and
dropping upon the floor at his feet.

Darke sprung into the room at a single bound.

“Vinnie!” he cried. “Where is Vinnie?”

“Gone!” gasped Clancy.

“Gone! My God! what do you mean?”

“The Indians made her a prisoner!”

“Vinnie! My Vinnie a prisoner in the hands of those devils! And you


let them take her?”

“Stop!” exclaimed the young man, while an expression of keen pain


swept across his face. “I could not help it! I would gladly have laid
down my life to save hers! For a time we fought them side by side.
There are five dead Indians here on the floor. She killed two of
them. Only two of the chambers of her revolver were loaded; and
after they were emptied I fought them alone, shielding her form
with mine. Then I was set upon from all sides at once, and she was
snatched away from me. I did all I could. She was my Vinnie, too,
Mr. Darke, and I will wrest her from the power of that red demon or
die in the attempt! You do me injustice!”

“Pardon me, boy,” said the woodman, extending his hand, which was
readily taken by Clancy. “I was mad! I did not mean what I said—
please forget it if you can. If we can not get her back, I believe I
shall go crazy!”

“Oh, we can get her back—we must!” cried the young hunter. “We
must get help and follow them and take her out of their hands or
die!”

“How many are there in the party?” asked Darke.

“I am not certain. At the beginning I think there were about a dozen


or fifteen—I do not know exactly. Five are dead.”

“There are seven dead!” replied Darke. “I shot two outside!”

“Then there must be a half-dozen, more or less, that have escaped,


taking Vinnie with them.”

“They have been gone twenty minutes,” said the woodman; 85


“and we must act at once!”

“We can not follow them to-night,” said Clancy.

“Not to-night! Why?” and Darke evinced disappointment.

“Because they are mounted. They left their horses at the edge of the
forest. It is scarcely three miles away. Before we could overtake
them they would be miles out on the prairie, riding at their horses’
best speed. We can do nothing alone, and horses are indispensable
—we must have them.”

“Where can we get them?” Darke asked, admitting to himself the


truth of Clancy’s reasoning.

“At the settlement. We can have every thing ready to-night and start
before daybreak.”

“Who do you think we had better get to go with us?” asked Darke.
“We must have good men.”

“I think we can do no better than to have Pete Wimple for one,” said
Clancy. “A truer and braver man can not be found in the North-west.”

“True,” said the woodman. “And the big hunter for another!”
“If we could only get him!” exclaimed Clancy.

“I’m sure he will go. He hates the Indians with an undying hatred,
and is glad of any opportunity to wreak his terrible vengeance on
them for the cold-blooded butchery of his aged parents.”

“Yes,” said the young hunter, “he told me his story. What a fiend
incarnate the chief is!”

“You mean Ku-nan-gu-no-nah. Was he with the party?”

“He led them,” said Clancy. “I think he instigated the attack to get
possession of Vinnie.”

The youth shuddered as he thought what might be her fate in such


hands. How he longed for the morning.

Darke remembered the promise he had made to Leander Maybob


the day before, and wondered if he could restrain himself from
shooting the red demon at sight.

“Do you think we will need any one else?” he asked.

“I think not. There will be four of us; and Pete Wimple and the giant
hunter will be a host in themselves.”

“We must make all our preparations to-night,” said Darke, “so as to
be far on our way at daylight.”

“Yes. We must— What’s that? It sounds like fire!” 86

A strange sound had arrested his attention.

“It is fire!” replied Darke. “I saw one of the devils fire the cabin. It
must be all in a light blaze before this time!”

“Then it was fired before you came in?”


“Yes. It was set at the rear, and that is the reason you have not seen
or heard it till now. The flames were climbing the roof as I crossed
the clearing. But we must not stay here. One of us must go to the
settlement and the other to the cavern to-night. Do you think you
can walk well enough to undertake to get to the settlement? Your
ankles must be—”

“Yes,” and the look on his face confirmed what he said, “I could do
any thing—brave any thing for her! There is nothing that I would not
attempt to save her from pain—nothing that I would not dare, to
make her happy! Vinnie is more to me than my life, Mr. Darke! To-
day, before those red devils came to tear her away from me, she
promised to become my wife.”

“I believe you, boy!” exclaimed Darke. “I could not intrust her to the
protecting love of a better man. If we can only save her she shall be
yours!”

“Thank you,” said the young man, earnestly. “We must save her from
that demon’s power! The thought that she is in his hands is
maddening! But we must act. I will go to the settlement and obtain
horses and enlist Pete Wimple in our cause, while you proceed to
the cave to secure the services of the big hunter. I’m sure he will not
refuse us his aid.”

“Right,” assented Darke. “Where shall be our place of rendezvous?”

“Near the big pine tree at the edge of the forest. We must be
mounted and on our way before daylight.”

The fire had caught in the great oak trees that had been left close
up by the walls of the woodman’s home as a partial protection
against wind and storm, and the flames, shooting heavenward, cast
a lurid glow over the dark forest for quite a distance in every
direction.
The two men hastened away, the burning cabin lighting their way
through the wood, Death, the blood-hound keeping close to 87
Darke and manifesting his sense of the calamity that had
overtaken them by giving utterance ever and anon to low, sorrowful
whines.
CHAPTER XV.
WHAT THE SCOUTS FOUND.

When the sun rose the next morning—for the day broke clear and
cloudless with a keen, frosty atmosphere—its rays fell on a heap of
smoldering ruins, encircled by a dozen charred trees burnt and
blackened to their very tops. This was all that remained of Emmett
Darke’s cabin home.

The four men, Darke, Clancy Vere, Leander Maybob, the giant
hunter, and Pete Wimple, a tried and trusty scout and Indian-fighter,
were at the appointed place of rendezvous at a very early hour, and,
well mounted on four fleet, strong horses that Clancy and the scout
had obtained at the settlement, they were at daybreak dashing over
the smooth, level prairie in pursuit of Ku-nan-gu-no-nah and his
party.

For hours they kept on at a rapid, even gallop, which they neither
quickened nor slackened. Clancy and the scout, riding side by side
and keeping a sharp look-out ahead for any signs of the enemy,
while Darke and the giant hunter were ever on the alert to guard
against the approach of any hostile party from the rear.

None of the four had spoken more than a few words since they left
the big pine, hours before, even Leander Maybob, usually so
loquacious, maintaining a thoughtful and unbroken silence.

The day continued as it had dawned, clear and sun-shiny, the pure,
bracing air inspiring the little band to more than common vigilance
and alertness, while it added fresh vigor to their steeds, and they
kept on at the same quick, regular rate of speed until mid-day
without meeting with adventure of any kind.
Then Pete Wimple drew his horse up suddenly, and in 88
obedience to his low-spoken command, the three others
reined in their horses.

“What is it, Pete?” asked Clancy.

“I don’t know for sartin,” and the scout, shading his eyes with his
hand, looked long and earnestly across the wide, grassy plain before
them. Following the direction of his gaze, the others saw dimly in the
distance a thin blue cloud of smoke rising from the surface of the
prairie.

“It’s a fire!” said Darke.

“That it are!” confirmed the big hunter.

“Can it be a camp-fire?” asked Clancy.

“Very likely,” said the scout. “I think as how it’s some-’eres ’long the
line of the emigrant trail. We’ll strike it purty quick—it’s jist ahead
thar—and we’ve got to foller it for severil hours. We’ve got to pass
that fire, and afore we get too cluss, I want to know what it means!”

“It mought be whites, an’ ag’in it mought be reds!” said Leander


Maybob, riding to the front and examining the thin, vapory cloud for
a moment or two. “It mought be emigrants takin’ thar grub and it
moughtn’t, ye see. Prob’ly ’tis and prob’ly ’tain’t, as my uncle Peter
said when Elder Tugwoller axed him if his youngest-born son war a
boy or a gal!”

The others could not restrain a laugh at this; and when their
merriment had subsided Darke asked:

“What do you think is best to be done, Wimple? You and Leander


are learned in every department of prairie life and warfare, while
Clancy and I are the merest novices. We shall trust ourselves and
our enterprise in your hands.”
“I think, as it’s about grub time, you and me had better ride ahead
and diskiver, if we can, whether there’s white men or Injuns or
suthin’ else around that are smudge, or whether its jest a muskeeter
smoke, while Low-lander, as you calls him, and the boy busies
’emselves about gittin’ suthin’ for our appetites ag’in’ our return.”

“I agree with ye thar!” said the giant, “as Elder Tugwoller remarked
to my daddy when he expressed his opinion as how donations was a
good institution; but my name ain’t Low-lander.”

“What’s in a name?” laughed Darke as he and the scout rode away.

“Thar’s a good deal in names, I notice,” said the big hunter, 89


half musingly, as he swung his long left leg over his horse’s
head and slipped to the ground. “I reckon thar’s a sight o’ valler in
names. If ’twasn’t for folks bein’ named so’s to tell ’em apart, they’d
git all mixed and twisted up so a feller couldn’t tell w’ich from t’uther
or t’uther from w’ich! Now I don’t go very strong for seein’ things git
all mixed and twisted up so’s ye can’t discrimernate w’ich from w’ich.
If it hadn’t been fer jest sich a durn’d mixin’ and twistin’ of two
different things together in my head, I’d likely now be a married
man, livin’ as happy as a hornet in yer breecherloons, down to old
Maybob Center in Massachusetts, the Bay State and capital of
Bosting, the hub of the univarsal terry firmy. It’s an awful world
we’re livin’ in,” he went on, as he tied his horse, as Clancy had
already done, by means of lariats they had brought with them. “It’s
an awful world! I never know’d a man to go cl’ar through it ’ithout
gittin’ the wind knocked outen him somehow! It’s this mixin’ an’
twistin’ as does it all! It’s that as caused all my misery and pains and
heart-longin’s, and sighin’s and so forth and so on. I know folks in
gin’ral wouldn’t go for to take me for a lovyer—you, now, youngster,
look more like a lovyer than I do; sorter like a despondin’ lovyer,
more’n any thing. But don’t ye git down-hearted now. We’re a-goin’
to git yer sweetheart back to-day! I’ll tell you how I found out about
it,” he explained, noting Clancy’s look of surprise, “I heerd ye talkin’
about her afore ye come to, fairly, yisterday. I didn’t mean ter hear
yer, and didn’t go fer to pry into any of yer secrets; but I couldn’t
help hearin’ ye say ev’ry few minits, ‘Vinnie!’ ‘Vinnie!’ I heerd Darke
say his gal’s name was that to-day; and so I put this and that
together and know’d you was her lovyer. I’ll tell you ’bout my gal an’
my love affair, and then we’ll be even. All our trouble come of this
mixin’ an’ twistin’, as I told you afore. Elder Tugwoller’s niece, Sally
Niver, as purty a gal as ever wore caliker—she used to live along o’
the Elder and his wife—and me got acquainted with each other to
singin’ school, and afore we know’d it we was both on us purty nigh
as deep into love as Lord Lovel and the Lady Nancy. The Elder didn’t
’prove of the match, and Sally an’ me uster spark on the sly. The
Elder found it out and licked Sally and forbid her ever to speak 90
to me ag’in. She cum right straight and told me, and said as
how the Elder and Miss Tugwoller would be away Saturday night
over to the widder Mork’s and wanted me to come down an’ see her
while they was gone. I rigged up and went down; and jest as I got
inside the yard I see Sally cummin, down the path to meet me, and
the tears was a-streamin’ down her face. ‘They ain’t gone, deary!’
sez she, ‘and if they see you we’ll be in an awful pickle!’ I couldn’t go
away without inquirin’ what was the matter. ‘Oh!’ sez she, ‘I’ve had
to take—uncle’s bin a-givin’ me—’ ‘Another lickin’ I’ll be bound!’ sez
I. ‘Sally, yer mine, afore Heaven, and I’m a-goin’ to trounce that old
cuss within an inch of his life for abusin’ ye so, if he is the preacher!’
‘Oh dear!’ sez she. ‘You don’t understand he—oh, what’ll you do?
Thar he comes now!’ And sure enough, I looked up and thar come
the Elder down the path a-makin’ motions and a-swingin’ a big
hosswhip. I thought he was a-goin’ to lick Sally ag’in, and she
screamed and I jumped afore her. Jest then the hosswhip cracked
round my legs. ‘Young man,’ sez the Elder, ‘you’ve got things kinder
mixed and twisted up, like, in your mind. Your mind’s considerably
mixed and twisted. You don’t understand as how I don’t want ye
here at all, and you’ve got mixed and twisted up about the lickin’,
like. I hain’t bin a-givin’ my niece a cowhidin’; I jest give her a dose
of peppersass for a cold, and that’s what brings the water outen her
eyes. I’m goin’ to give the cowhidin’ to you!’ And he axed the blessin’
and commenced. The gad played kinder lively for a minit, then I
jerked it outen his hand and throw’d it over into the garden, and sez
I, ‘Elder, if you think I’m goin’ to stand sich you must be kinder
mixed and twisted up, like, in your idees!’ Then I knocked him down
and kissed Sally good-by and walked away. I hain’t never seen her
since. The Elder sent her away to school and I come West—and
that’s the end on’t all. I s’pose she’s married long ago!” he finished,
sadly. “She was jest the sort of gal as ketches men! It was all owin’
to my mixed and twisted state of mind concernin’ the lickin’ and the
peppersass!”

By the time they had prepared the noon-day meal, Clancy saw Darke
and Wimple coming back; and in less than ten minutes they 91
threw themselves from their horses a few rods away, and after
tethering them, came up with rapid strides.

“What did you find?” asked Clancy eagerly; “any signs of Vinnie or
her captors?”

“We found some of the devil’s own handiwork!” answered the scout,
a dark, fierce look on his usually pleasant face that the young hunter
never saw there before.

“The smoke we saw arises from two burning emigrant wagons that
the Indians have plundered and then set fire to!” said Darke. “One
man, evidently the guide, lay dead and scalped, his body, with those
of three savages who had been shot in the affray, half burned up in
the fire! The remainder of the party, which I should judge was not
very large, have either escaped or been made prisoners.”

“It is Ku-nan-gu-no-nah’s work!” said Clancy.

“I’ve made up my mind to settle with him purty soon!” said Leander
Maybob, sternly. “His time’s most up!”
CHAPTER XVI.
THE PHANTOM RIDER!

Five minutes later the little party was on the move again.

About the middle of the afternoon they halted for a moment’s


consultation. Darke was not surprised when the scout informed him
that the Indian encampment was not more than a half-dozen miles
distant. He had long been anxious to reach the village. The suspense
was growing to be almost unendurable to him.

At first, Leander Maybob took little part in the conversation and bent
his gaze anxiously every few minutes upon the horizon in the
direction whence they had come.

“Would you advise a bold charge through the Indian encampment?”


asked Clancy. “Do you think we would be likely to accomplish our
object in that way?”

The scout thought not. The savages might be on the look-out for
some such movement as that, as they would probably expect 92
that an attempt would be made to rescue Vinnie, in which
case they would run great risk of falling into some trap set for them
by the Indians, if they approached the encampment boldly and in
the full glare of the sunlight. Their party was too small to hazard
being taken at so great a disadvantage. They dared not show
themselves openly in the camp of their enemies. The odds would be
too great against them.

“No!” said Wimple, emphatically. “We mustn’t try such a plan as that.
It would be worse than useless! What we do must be done by
stratagem. There’s a steep bluff, only ’tain’t a bluff, neither—thar
ain’t no river under it—jist back of the Injin camp. This hill’s all
grown over with low scrub-oak and other stuff so thick ye can’t see
a rod any way. If we could only git up there and hide till arter dark,
and then two or three of us jist step quietly down and release the
prisoners, leaving some one to have the horses ready to mount at
an instant’s warnin’, I think we could git the gal cl’ar without much
blood-lettin’, and maybe the other prisoners, whoever they are. It’s
the best plan I can think of now.”

Darke agreed with the scout that nothing could be done by daylight,
but he was getting very impatient.

“I think,” said the big hunter, “as how ye’re partly right in yer
calkerlations and mayhap partly wrong. I don’t believe as how us
four rushing into the imps’ nest would do much good. We’d be very
likely to git our little lump of lead, every one on us, and that’d be the
end on’t all; but instid o’ climbin’ the hill, if ye’ll jist take the advice
of one who has fit Injins some, and stop in the border of the wood,
down level with the edge of the prairie, and wait and see what
happens, I b’lieve we can do suthin’ as ’ll amount to suthin’. I’ve
knowed some of the best kind of jobs to be did in gittin’ away
prisoners from the reds, jist by watchin’ and takin’ advantage of
accidents and the like. If you’ll all do jist as I say and not git
flustered or go to gittin’ away up there on top of the hill, I’ll promise
that every prisoner in the Indian camp shall be safe before sundown
—yes, in less than two hours. You don’t know what amazin’ helps
accidents is sometimes, in sich cases as this one!”

“Can you do it?” asked Darke, eagerly.

“Yes.”

“What do you mean by accidents?” inquired Pete Wimple. 93


“What d’ye expect’s goin’ to happen to-day?”

“Thar’s no tellin’ exactly,” replied the big hunter. “A feller can’t most
always tell what is goin’ to take place. But I’m safe in guaranteein’
thirty or forty of them reds one of the tallest accidents in a little
while—’bout as soon as we can git to their camp—they ever had any
ijee of!”

“Do you expect to kill as many as that?” asked Clancy, in some


wonderment.

“I calkerlate as how, if yer a mind to foller my lead, we can e’en


a’most clean out the nest and git yer gal and the rest of the
prisoners away safe, besides! What do ye say? Shall I go ahead?”

“Yes,” cried all three with one voice. “You shall lead us!”

“I believe you can do what you say!” added Darke. “But remember
that a mistake on our part might prove fatal to Vinnie and the
others!”

“There shan’t be no balks or mistakes!” said the giant, in a tone of


assurance, taking his place at the head of the party. “We’ve got to
leave this emigrant road here and take to the left a little. An hour’s
sharp ridin’ ’ll bring us to the Injun camp. Let’s be movin’ on.”

And tightening their reins, the quartette dashed away.

There was a plain trail, left by Ku-nan-gu-no-nah’s band, leading


directly to the encampment of the savages. The little party followed
this for a while at a swift gallop, and then in obedience to a low,
tersely-spoken command from their leader, left it suddenly, and
bearing still further to the left, dashed for a few minutes through the
edge of a broad belt of timber lying along the base of a range of low
hills, halting at last in a chapparal not more than a hundred yards
distant from the Indian village.

“Here we are,” said Leander Maybob, throwing himself off his horse.
“Jist git off yer nags and stretch yerselves a little, while I take a look
outside. Make the most outen your restin’-spell, for I can tell yer that
ye won’t have long to lay idle. I’m expectin’ an accident soon!”
And with these strange words which the three men were assured
held more meaning than they expressed, the giant strode 94
away and disappeared from view among the shrubbery. In less
than five minutes he came back, and his face showed that the result
of his reconnoissance was satisfactory.

“There’ll be an accident soon,” said he.

“How soon?” queried the scout.

“Inside of a quarter of an hour.”

“Will it assist us in any manner?” inquired Darke.

“Yes; it’ll be the makin’ of our job.”

“How?” asked Clancy.

“It’s onsartin,” replied the big hunter. “Accidents is onsartin things;


but this one ’ll be sartin to help us if we’re ready to help ourselves.
I’ve noticed as how the same accident don’t happen twice, any
more’n a boy takes his fust chaw of terbacker twice. ’Tain’t anyways
likely this ’ere accident we’ve been waitin’ for ’ll happen more’n
onc’t. So we must be ready to take advantage of it jest at the right
minit! Now then, how many shots have we got altogether?”

“I’ve got a six-shooter and a rifle, both loaded,” said the scout.

“Seven,” said Leander, counting.

“And I’ve got six,” said Clancy.

“Thirteen,” counted the big hunter.

“And I’ve got two revolvers and a rifle,” said the scout.

“Twenty-six,” said the giant, “and I’ve got seven more—thirty-three


in all. If there ain’t any of ’em wasted, we can shoot jist thirty-three
Injuns without stopping to load! Now git on yer horses and stick yer
pistols in yer belts and hold yer rifles ready for instant use. I want to
take one more look-out, and I’ll be with ye in a minit.”

The big hunter’s prompt manner and cool, baffling way of talking
had inspired the three men with the utmost confidence in himself
and his power to bring their enterprise to a successful termination,
and they obeyed his orders implicitly. In a moment they were
mounted, their unerring rifles ready for use at a moment’s warning.

“Are we going to dash into the encampment?” asked Clancy,


examining the lock of his revolver.

“It looks like it,” answered the scout, sententiously.

“What can the accident be?” questioned Darke.

“That’s a riddle!” said Wimple.

“And a hard one to guess!” added the young hunter. 95

Just then the giant came running through the chapparal, and hastily
seizing his ride, which he had left standing against a tree, threw
himself upon the back of his horse and rode to the head of the little
band of wondering, anxious men.

“Wait a minit!” he half whispered.

There was a moment of dead silence, the four men almost holding
their breath in their suspense.

Then a shriek rung out on the air—a shriek that was half a wail, half
a curse—so weird and so unearthly that for a moment the blood
seemed to stand still in the veins of the three startled men.

“My God! What is that?” cried Darke.


“It’s the accident we’ve bin waitin’ for,” said the big hunter, calmly.
“It’s purty near time for us to take advantage of it. Git ready.”

At that moment there came from the direction of the Indian


encampment an almost deafening report, followed instantly by cries
of agony and fear.

“Now’s our time!” cried the big hunter. “Shoot down every red-skin
you see! But don’t harm a hair of Ku-nan-gu-no-nah’s head if you
can help it! Take him alive!!”

As they cleared the chapparal, they saw a sight for which even the
terrible cry of a moment before had not prepared them.

It was a gigantic human skeleton, standing upright on the back of a


milk-white horse that moved with more than the speed of the wind.
In the bony, grisly arms of the Phantom Rider was Vinnie Darke!

You might also like