100% found this document useful (1 vote)
18 views

Building Java Programs - A Back to Basics Approach Stuart Reges download

The document discusses the fourth edition of 'Building Java Programs: A Back to Basics Approach' by Stuart Reges and Marty Stepp, designed for introductory computer science courses. It emphasizes a layered teaching approach, gradually introducing programming concepts and includes new content on functional programming with Java 8 and image manipulation. The textbook aims to improve student success rates in computer science courses by focusing on problem-solving and algorithmic thinking.

Uploaded by

qiiqxeb008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
18 views

Building Java Programs - A Back to Basics Approach Stuart Reges download

The document discusses the fourth edition of 'Building Java Programs: A Back to Basics Approach' by Stuart Reges and Marty Stepp, designed for introductory computer science courses. It emphasizes a layered teaching approach, gradually introducing programming concepts and includes new content on functional programming with Java 8 and image manipulation. The textbook aims to improve student success rates in computer science courses by focusing on problem-solving and algorithmic thinking.

Uploaded by

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

Building Java Programs - A Back to Basics

Approach Stuart Reges download

https://textbookfull.com/product/building-java-programs-a-back-
to-basics-approach-stuart-reges-2/

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


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

Building Java Programs - A Back to Basics Approach


Stuart Reges

https://textbookfull.com/product/building-java-programs-a-back-
to-basics-approach-stuart-reges-2/

Building Java Programs: A Back to Basics Approach, 5th


Edition Stuart Reges

https://textbookfull.com/product/building-java-programs-a-back-
to-basics-approach-5th-edition-stuart-reges/

Building Python Programs 1st Edition Stuart Reges

https://textbookfull.com/product/building-python-programs-1st-
edition-stuart-reges/

Simpler Living Back to Basics Guides 2nd Edition Jeff


Davidson

https://textbookfull.com/product/simpler-living-back-to-basics-
guides-2nd-edition-jeff-davidson/
College physics : a strategic approach 4th Edition
Stuart Field

https://textbookfull.com/product/college-physics-a-strategic-
approach-4th-edition-stuart-field/

Artificial Intelligence: A Modern Approach 4th Edition


Stuart Russell

https://textbookfull.com/product/artificial-intelligence-a-
modern-approach-4th-edition-stuart-russell/

RESTful Java Web Services A pragmatic guide to


designing and building RESTful APIs using Java 3rd
Edition Balachandar

https://textbookfull.com/product/restful-java-web-services-a-
pragmatic-guide-to-designing-and-building-restful-apis-using-
java-3rd-edition-balachandar/

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/

Back Trouble A New Approach to Prevention and Recovery


based on the Alexander Technique Deborah Caplan

https://textbookfull.com/product/back-trouble-a-new-approach-to-
prevention-and-recovery-based-on-the-alexander-technique-deborah-
caplan/
GLOBAL GLOBAL
EDITION EDITION

For these Global Editions, the editorial team at Pearson has Building Java™ Programs

Building Java™ Programs


collaborated with educators across the world to address a
wide range of subjects and requirements, equipping students A Back to Basics Approach

A Back to Basics Approach


with the best possible learning tools. This Global Edition
preserves the cutting-edge approach and pedagogy of the FOURTH EDITION
original, but also features alterations, customization, and
adaptation from the North American version.
Stuart Reges • Marty Stepp

EDITION
FOURTH
This is a special edition of an established
title widely used by colleges and universities

Stepp
Reges
throughout the world. Pearson published this
exclusive edition for the benefit of students
outside the United States and Canada. If you
purchased this book within the United States

EDITION
GLOBAL
or Canada, you should be aware that it has
been imported without the approval of the
Publisher or Author.

Pearson Global Edition

Reges_04_129216168X_Final.indd 1 08/11/16 5:37 PM


Fourth Edition
Global Edition

Building Java Programs


A Back to Basics Approach

Stuart Reges
University of Washington

Marty Stepp
Stanford University

Boston Columbus Indianapolis New York San Francisco Hoboken


Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montreal Toronto
Delhi Mexico City Sao Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo

A01_REGE1686_04_GE_FM.indd 1 17/11/16 3:27 PM


Vice President, Editorial Director: Marcia Horton Project Manager: Lakeside Editorial Services L.L.C.
Acquisitions Editor: Matt Goldstein Senior Specialist, Program Planning and Support:
Editorial Assistant: Kristy Alaura Maura Zaldivar-Garcia
Acquisitions Editor, Global Editions: Sourabh Maheshwari Senior Manufacturing Controller, Global Editions: Kay
VP of Marketing: Christy Lesko Holman
Director of Field Marketing: Tim Galligan Media Production Manager, Global Editions: Vikram
Product Marketing Manager: Bram Van Kempen Kumar
Field Marketing Manager: Demetrius Hall Cover Design: Lumina Datamatics
Marketing Assistant: Jon Bryant R&P Manager: Rachel Youdelman
Director of Product Management: Erin Gregg R&P Project Manager: Timothy Nicholls
Team Lead, Program and Project Management: Inventory Manager: Meredith Maresca
Scott Disanno Cover Art: © Westend61 Premium/Shutterstock.com
Program Manager: Carole Snyder Full-Service Project Management:
Project Editor, Global Editions: K.K. Neelakantan Apoorva Goel/Cenveo® Publisher Services

The authors and publisher of this book have used their best efforts in preparing this book. These efforts include the
development, research, and testing of the theories and programs to determine their effectiveness. The authors and
publisher make no warranty of any kind, expressed or implied, with regard to these programs or to the documentation
contained in this book. The authors and publisher shall not be liable in any event for incidental or consequential damages
in connection with, or arising out of, the furnishing, performance, or use of these programs.
Acknowledgements of third-party content appear on pages 1219–1220, which constitute an extension of this copyright page.
PEARSON, and MYPROGRAMMINGLAB are exclusive trademarks in the U.S. and/or other countries owned by
Pearson Education, Inc. or its affiliates.
Pearson Education Limited
Edinburgh Gate
Harlow
Essex CM20 2JE
England
and Associated Companies throughout the world
Visit us on the World Wide Web at:
www.pearsonglobaleditions.com
© Pearson Education Limited 2018
The rights of Stuart Reges and Marty Stepp to be identified as the authors of this work have been asserted by them
in accordance with the Copyright, Designs and Patents Act 1988.
Authorized adaptation from the United States edition, entitled Building Java Programs: A Back to Basics Approach,
4th Edition, ISBN 978-0-13-432276-6, by Stuart Reges and Marty Stepp published by Pearson Education © 2017.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any
form or by any means, electronic, mechanical, photocopying, recording or otherwise, without either the prior written
permission of the publisher or a license permitting restricted copying in the United Kingdom issued by the Copyright
Licensing Agency Ltd, Saffron House, 6–10 Kirby Street, London EC1N 8TS.
All trademarks used herein are the property of their respective owners. The use of any trademark in this text does not vest
in the author or publisher any trademark ownership rights in such trademarks, nor does the use of such trademarks imply
any affiliation with or endorsement of this book by such owners.
British Library Cataloguing-in-Publication Data
A catalogue record for this book is available from the British Library
10 9 8 7 6 5 4 3 2 1
ISBN 10: 1-292-16168-X
ISBN 13: 978-1-292-16168-6
Typeset in Monotype by Cenveo Publisher Services
Printed and bound in Malaysia.

A01_REGE1686_04_GE_FM.indd 2 14/12/16 6:05 PM


Preface

The newly revised fourth edition of our Building Java Programs textbook is designed
for use in a two-course introduction to computer science. We have class-tested it with
thousands of undergraduates, most of whom were not computer science majors, in our
CS1-CS2 sequence at the University of Washington. These courses are experiencing
record enrollments, and other schools that have adopted our textbook report that stu-
dents are succeeding with our approach.
Introductory computer science courses are often seen as “killer” courses with high
failure rates. But as Douglas Adams says in The Hitchhiker’s Guide to the Galaxy, “Don’t
panic.” Students can master this material if they can learn it gradually. Our textbook uses
a layered approach to introduce new syntax and concepts over multiple chapters.
Our textbook uses an “objects later” approach where programming fundamentals
and procedural decomposition are taught before diving into object-oriented program-
ming. We have championed this approach, which we sometimes call “back to basics,”
and have seen through years of experience that a broad range of scientists, engineers,
and others can learn how to program in a procedural manner. Once we have built a
solid foundation of procedural techniques, we turn to object-oriented programming.
By the end of the course, students will have learned about both styles of programming.
Here are some of the changes that we have made in the fourth edition:

• New chapter on functional programming with Java 8. As explained below, we


have introduced a chapter that uses the new language features available in Java 8
to discuss the core concepts of functional programming.
• New section on images and 2D pixel array manipulation. Image manipula-
tion is becoming increasingly popular, so we have expanded our DrawingPanel
class to include features that support manipulating images as two-dimensional
arrays of pixel values. This extra coverage will be particularly helpful for stu-
dents taking an AP/CS A course because of the heavy emphasis on two-dimen-
sional arrays on the AP exam.
• Expanded self-checks and programming exercises. Many chapters have
received new self-check problems and programming exercises. There are roughly
fifty total problems and exercises per chapter, all of which have been class-tested
with real students and have solutions provided for instructors on our web site.

Since the publication of our third edition, Java 8 has been released. This new version
supports a style of programming known as functional programming that is gaining in

A01_REGE1686_04_GE_FM.indd 3 17/11/16 3:27 PM


4 Preface

popularity because of its ability to simply express complex algorithms that are more
easily executed in parallel on machines with multiple processors. ACM and IEEE have
released new guidelines for undergraduate computer science curricula, including a
strong recommendation to cover functional programming concepts.
We have added a new Chapter 19 that covers most of the functional concepts
from the new curriculum guidelines. The focus is on concepts, not on language
features. As a result, it provides an introduction to several new Java 8 constructs
but not a comprehensive coverage of all new language features. This provides
flexibility to instructors since functional programming features can be covered as
an advanced independent topic, incorporated along the way, or skipped entirely.
Instructors can choose to start covering functional constructs along with tradi-
tional constructs as early as Chapter 6. See the dependency chart at the end of this
section.
The following features have been retained from previous editions:

• Focus on problem solving. Many textbooks focus on language details when


they introduce new constructs. We focus instead on problem solving. What new
problems can be solved with each construct? What pitfalls are novices likely
to encounter along the way? What are the most common ways to use a new
construct?
• Emphasis on algorithmic thinking. Our procedural approach allows us to
emphasize algorithmic problem solving: breaking a large problem into smaller
problems, using pseudocode to refine an algorithm, and grappling with the chal-
lenge of expressing a large program algorithmically.
• Layered approach. Programming in Java involves many concepts that are dif-
ficult to learn all at once. Teaching Java to a novice is like trying to build a house
of cards. Each new card has to be placed carefully. If the process is rushed and
you try to place too many cards at once, the entire structure collapses. We teach
new concepts gradually, layer by layer, allowing students to expand their under-
standing at a manageable pace.
• Case studies. We end most chapters with a significant case study that shows
students how to develop a complex program in stages and how to test it as it is
being developed. This structure allows us to demonstrate each new program-
ming construct in a rich context that can’t be achieved with short code exam-
ples. Several of the case studies were expanded and improved in the second
edition.
• Utility as a CS1+CS2 textbook. In recent editions, we added chapters that extend
the coverage of the book to cover all of the topics from our second course in com-
puter science, making the book usable for a two-course sequence. Chapters 12–19
explore recursion, searching and sorting, stacks and queues, collection implemen-
tation, linked lists, binary trees, hash tables, heaps, and more. Chapter 12 also

A01_REGE1686_04_GE_FM.indd 4 17/11/16 3:27 PM


Preface 5

received a section on recursive backtracking, a powerful technique for exploring a


set of possibilities for solving problems such as 8 Queens and Sudoku.

Layers and Dependencies


Many introductory computer science books are language-oriented, but the early chap-
ters of our book are layered. For example, Java has many control structures (including
for-loops, while-loops, and if/else-statements), and many books include all of these
control structures in a single chapter. While that might make sense to someone who al-
ready knows how to program, it can be overwhelming for a novice who is learning how
to program. We find that it is much more effective to spread these control structures
into different chapters so that students learn one structure at a time rather than trying
to learn them all at once.
The following table shows how the layered approach works in the first six chapters:

Programming
Chapter Control Flow Data Techniques Input/Output

1 methods String literals procedural println, print


decomposition
2 definite loops (for) variables, local variables,
expressions, int, class constants,
double pseudocode
3 return values using objects parameters console input, 2D
graphics (optional)
4 conditional char pre/post conditions, printf
(if/else) throwing exceptions
5 indefinite loops boolean assertions,
(while) robust programs
6 Scanner token/line-based file I/O
file processing

Chapters 1–6 are designed to be worked through in order, with greater flexibility
of study then beginning in Chapter 7. Chapter 6 may be skipped, although the case
study in Chapter 7 involves reading from a file, a topic that is covered in Chapter 6.

A01_REGE1686_04_GE_FM.indd 5 17/11/16 3:27 PM


6 Preface

The following is a dependency chart for the book:

Chapters 1-6
Programming Fundamentals

Chapter 7 Chapter 8 Chapter 9


Arrays Classes Functional Programming
(except section 19.5)

Chapter 12 Chapter 9
Recursion Inheritance, Chapter 19
Interfaces Section 19.5

Chapter 13
Searching, Chapter 10
Sorting ArrayLists

Chapter 11
Collections

Chapter 14
Chapter 15 Stacks,
Implementing Queues
Collections

Chapter 16
Linked Lists

Chapter 17
Binary Trees

Chapter 18
Hashing,
Heaps

Supplements
Answers to all self-check problems appear on the web site and are accessible to
anyone. Our web site has the following additional resources for students:
• Online-only supplemental chapters, such as a chapter on creating Graphical User
Interfaces

A01_REGE1686_04_GE_FM.indd 6 17/11/16 3:27 PM


Preface 7

• Source code and data files for all case studies and other complete program
examples
• The DrawingPanel class used in the optional graphics Supplement 3G

Our web site has the following additional resources for teachers:

• PowerPoint slides suitable for lectures


• Solutions to exercises and programming projects, along with homework specifi-
cation documents for many projects
• Sample exams and solution keys
• Additional lab exercises and programming exercises with solution keys
• Closed lab creation tools to produce lab handouts with the instructor’s choice
of problems integrated with the textbook

The materials are available at www.pearsonglobaleditions.com/reges.

MyProgrammingLab
MyProgrammingLab is an online practice and assessment tool that helps students fully
grasp the logic, semantics, and syntax of programming. Through practice exercises
and immediate, personalized feedback, MyProgrammingLab improves the program-
ming competence of beginning students who often struggle with basic concepts and
paradigms of popular high-level programming languages. A self-study and homework
tool, the MyProgrammingLab course consists of hundreds of small practice exercises
organized around the structure of this textbook. For students, the system automatically
detects errors in the logic and syntax of code submissions and offers targeted hints that
enable students to figure out what went wrong, and why. For instructors, a comprehen-
sive grade book tracks correct and incorrect answers and stores the code inputted by
students for review.
For a full demonstration, to see feedback from instructors and students, or
to adopt MyProgrammingLab for your course, visit the following web site:
http://www.myprogramminglab.com/

VideoNotes
We have recorded a series of instructional videos to accompany the textbook. They are
VideoNote
available at the following web site: www.pearsonglobaleditions.com/reges.
Roughly 3–4 videos are posted for each chapter. An icon in the margin of the page
indicates when a VideoNote is available for a given topic. In each video, we spend

A01_REGE1686_04_GE_FM.indd 7 06/12/16 11:01 PM


8 Preface

5–15 minutes walking through a particular concept or problem, talking about the
challenges and methods necessary to solve it. These videos make a good supplement
to the instruction given in lecture classes and in the textbook. Your new copy of the
textbook has an access code that will allow you to view the videos.

Acknowledgments
First, we would like to thank the many colleagues, students, and teaching assistants
who have used and commented on early drafts of this text. We could not have written
this book without their input. Special thanks go to Hélène Martin, who pored over
early versions of our first edition chapters to find errors and to identify rough patches
that needed work. We would also like to thank instructor Benson Limketkai for spend-
ing many hours performing a technical proofread of the second edition.
Second, we would like to thank the talented pool of reviewers who guided us in
the process of creating this textbook:

• Greg Anderson, Weber State University


• Delroy A. Brinkerhoff, Weber State University
• Ed Brunjes, Miramar Community College
• Tom Capaul, Eastern Washington University
• Tom Cortina, Carnegie Mellon University
• Charles Dierbach, Towson University
• H.E. Dunsmore, Purdue University
• Michael Eckmann, Skidmore College
• Mary Anne Egan, Siena College
• Leonard J. Garrett, Temple University
• Ahmad Ghafarian, North Georgia College & State University
• Raj Gill, Anne Arundel Community College
• Michael Hostetler, Park University
• David Hovemeyer, York College of Pennsylvania
• Chenglie Hu, Carroll College
• Philip Isenhour, Virginia Polytechnic Institute
• Andree Jacobson, University of New Mexico
• David C. Kamper, Sr., Northeastern Illinois University
• Simon G.M. Koo, University of San Diego
• Evan Korth, New York University
• Joan Krone, Denison University
• John H.E.F. Lasseter, Fairfield University

A01_REGE1686_04_GE_FM.indd 8 17/11/16 3:27 PM


Preface 9

• Eric Matson, Wright State University


• Kathryn S. McKinley, University of Texas, Austin
• Jerry Mead, Bucknell University
• George Medelinskas, Northern Essex Community College
• John Neitzke, Truman State University
• Dale E. Parson, Kutztown University
• Richard E. Pattis, Carnegie Mellon University
• Frederick Pratter, Eastern Oregon University
• Roger Priebe, University of Texas, Austin
• Dehu Qi, Lamar University
• John Rager, Amherst College
• Amala V.S. Rajan, Middlesex University
• Craig Reinhart, California Lutheran University
• Mike Scott, University of Texas, Austin
• Alexa Sharp, Oberlin College
• Tom Stokke, University of North Dakota
• Leigh Ann Sudol, Fox Lane High School
• Ronald F. Taylor, Wright State University
• Andy Ray Terrel, University of Chicago
• Scott Thede, DePauw University
• Megan Thomas, California State University, Stanislaus
• Dwight Tuinstra, SUNY Potsdam
• Jeannie Turner, Sayre School
• Tammy VanDeGrift, University of Portland
• Thomas John VanDrunen, Wheaton College
• Neal R. Wagner, University of Texas, San Antonio
• Jiangping Wang, Webster University
• Yang Wang, Missouri State University
• Stephen Weiss, University of North Carolina at Chapel Hill
• Laurie Werner, Miami University
• Dianna Xu, Bryn Mawr College
• Carol Zander, University of Washington, Bothell

Finally, we would like to thank the great staff at Pearson who helped produce the
book. Michelle Brown, Jeff Holcomb, Maurene Goo, Patty Mahtani, Nancy Kotary,
and Kathleen Kenny did great work preparing the first edition. Our copy editors
and the staff of Aptara Corp, including Heather Sisan, Brian Baker, Brendan Short,

A01_REGE1686_04_GE_FM.indd 9 17/11/16 3:27 PM


10 Preface

and Rachel Head, caught many errors and improved the quality of the writing.
Marilyn Lloyd and Chelsea Bell served well as project manager and editorial assis-
tant respectively on prior editions. For their help with the third edition we would like
to thank Kayla Smith-Tarbox, Production Project Manager, and Jenah Blitz-Stoehr,
Computer Science Editorial Assistant. Mohinder Singh and the staff at Aptara, Inc.,
were also very helpful in the final production of the third edition. For their great
work on production of the fourth edition, we thank Louise Capulli and the staff of
Lakeside Editorial Services, along with Carole Snyder at Pearson. Special thanks go
to our lead editor at Pearson, Matt Goldstein, who has believed in the concept of our
book from day one. We couldn’t have finished this job without all of their hard work
and support.
Stuart Reges
Marty Stepp

Acknowledgments for the Global Edition


Pearson would like to thank and acknowledge the following people for their contribu-
tions to the Global Edition.

Contributor
Ankur Saxena, Amity University

Reviewers
Arup Bhattacharya, RCC Institute of Technology
Soumen Mukherjee, RCC Institute of Technology
Khyat Sharma

A01_REGE1686_04_GE_FM.indd 10 14/12/16 5:16 PM


A01_REGE1686_04_GE_FM.indd 11 12/12/16 5:31 pm
LOCATION OF VIDEO NOTES IN THE TEXT
www.pearsonglobaleditions.com/reges VideoNote

Chapter 1 Pages 57, 66


Chapter 2 Pages 91, 100, 115, 123, 136
Chapter 3 Pages 167, 182, 187, 193
Chapter 3G Pages 223, 241
Chapter 4 Pages 269, 277, 304
Chapter 5 Pages 350, 353, 355, 359, 382
Chapter 6 Pages 422, 435, 449
Chapter 7 Pages 484, 491, 510, 531
Chapter 8 Pages 561, 573, 581, 594
Chapter 9 Pages 623, 636, 652
Chapter 10 Pages 698, 703, 712
Chapter 11 Pages 742, 755, 763
Chapter 12 Pages 790, 798, 835
Chapter 13 Pages 860, 863, 869
Chapter 14 Pages 915, 922
Chapter 15 Pages 956, 962, 966
Chapter 16 Pages 998, 1005, 1018
Chapter 17 Pages 1063, 1064, 1074
Chapter 18 Pages 1099, 1118

12

A01_REGE1686_04_GE_FM.indd 12 17/11/16 3:27 PM


Brief Contents

Chapter 1 Introduction to Java Programming 27


Chapter 2 Primitive Data and Definite Loops 89
Chapter 3 Introduction to Parameters and Objects 163
Supplement 3G Graphics (Optional) 222
Chapter 4 Conditional Execution 264
Chapter 5 Program Logic and Indefinite Loops 341
Chapter 6 File Processing 413
Chapter 7 Arrays469
Chapter 8 Classes556
Chapter 9 Inheritance and Interfaces 613
Chapter 10 ArrayLists688
Chapter 11 Java Collections Framework 741
Chapter 12 Recursion780
Chapter 13 Searching and Sorting 858
Chapter 14 Stacks and Queues 910
Chapter 15 Implementing a Collection Class 948
Chapter 16 Linked Lists 991
Chapter 17 Binary Trees 1043
Chapter 18 Advanced Data Structures 1097
Chapter 19 Functional Programming with Java 8 1133
Appendix A Java Summary 1175
Appendix B The Java API Specification and Javadoc Comments 1190
Appendix C Additional Java Syntax 1196

13

A01_REGE1686_04_GE_FM.indd 13 14/12/16 5:17 PM


This page intentionally left blank

561590_MILL_MICRO_FM_ppi-xxvi.indd 2 24/11/14 5:26 PM


Contents

Chapter 1 Introduction to Java Programming 27


1.1 Basic Computing Concepts 28
Why Programming? 28
Hardware and Software 29
The Digital Realm 30
The Process of Programming 32
Why Java? 33
The Java Programming Environment 34
1.2 And Now—Java 36
String Literals (Strings) 40
System.out.println 41
Escape Sequences 41
print versus println 43
Identifiers and Keywords 44
A Complex Example: DrawFigures1 46
Comments and Readability 47
1.3 Program Errors 50
Syntax Errors 50
Logic Errors (Bugs) 54
1.4 Procedural Decomposition 54
Static Methods 57
Flow of Control 60
Methods That Call Other Methods 62
An Example Runtime Error 65
1.5 Case Study: DrawFigures 66
Structured Version 67
Final Version without Redundancy 69
Analysis of Flow of Execution 70

Chapter 2 Primitive Data and Definite Loops 89


2.1 Basic Data Concepts 90
Primitive Types 90
15

A01_REGE1686_04_GE_FM.indd 15 17/11/16 3:27 PM


16 Contents

Expressions 91
Literals 93
Arithmetic Operators 94
Precedence 96
Mixing Types and Casting 99
2.2 Variables 100
Assignment/Declaration Variations 105
String Concatenation 108
Increment/Decrement Operators 110
Variables and Mixing Types 113
2.3 The for Loop 115
Tracing for Loops 117
for Loop Patterns 121
Nested for Loops 123
2.4 Managing Complexity 125
Scope 125
Pseudocode 131
Class Constants 134
2.5 Case Study: Hourglass Figure 136
Problem Decomposition and Pseudocode 137
Initial Structured Version 139
Adding a Class Constant 140
Further Variations 143

Chapter 3 Introduction to Parameters


and Objects 163
3.1 Parameters 164
The Mechanics of Parameters 167
Limitations of Parameters 171
Multiple Parameters 174
Parameters versus Constants 177
Overloading of Methods 177
3.2 Methods That Return Values 178
The Math Class 179
Defining Methods That Return Values 182
3.3 Using Objects 186
String Objects 187
Interactive Programs and Scanner Objects 193
Sample Interactive Program 196

A01_REGE1686_04_GE_FM.indd 16 17/11/16 3:27 PM


Contents 17

3.4 Case Study: Projectile Trajectory 199


Unstructured Solution 203
Structured Solution 205

Supplement 3G Graphics (Optional) 222


3G.1 Introduction to Graphics 223
DrawingPanel 223
Drawing Lines and Shapes 224
Colors 229
Drawing with Loops 232
Text and Fonts 236
Images 239
3G.2 Procedural Decomposition with Graphics 241
A Larger Example: DrawDiamonds 242
3G.3 Case Study: Pyramids 245
Unstructured Partial Solution 246
Generalizing the Drawing of Pyramids 248
Complete Structured Solution 249

Chapter 4 Conditional Execution 264


4.1 if/else Statements 265
Relational Operators 267
Nested if/else Statements 269
Object Equality 276
Factoring if/else Statements 277
Testing Multiple Conditions 279
4.2 Cumulative Algorithms 280
Cumulative Sum 280
Min/Max Loops 282
Cumulative Sum with if 286
Roundoff Errors 288
4.3 Text Processing 291
The char Type 291
char versus int 292
Cumulative Text Algorithms 293
System.out.printf 295

4.4 Methods with Conditional Execution 300


Preconditions and Postconditions 300
Throwing Exceptions 300

A01_REGE1686_04_GE_FM.indd 17 17/11/16 3:27 PM


18 Contents

Revisiting Return Values 304


Reasoning about Paths 309

4.5 Case Study: Body Mass Index 311


One-Person Unstructured Solution 312
Two-Person Unstructured Solution 315
Two-Person Structured Solution 317
Procedural Design Heuristics 321

Chapter 5 Program Logic and Indefinite Loops 341


5.1 The while Loop 342
A Loop to Find the Smallest Divisor 343
Random Numbers 346
Simulations 350
do/while Loop 351

5.2 Fencepost Algorithms 353


Sentinel Loops 355
Fencepost with if 356

5.3 The boolean Type 359


Logical Operators 361
Short-Circuited Evaluation 364
boolean Variables and Flags 368
Boolean Zen 370
Negating Boolean Expressions 373

5.4 User Errors 374


Scanner Lookahead 375
Handling User Errors 377

5.5 Assertions and Program Logic 379


Reasoning about Assertions 381
A Detailed Assertions Example 382

5.6 Case Study: NumberGuess 387


Initial Version without Hinting 387
Randomized Version with Hinting 389
Final Robust Version 393

Chapter 6 File Processing 413


6.1 File-Reading Basics 414
Data, Data Everywhere 414

A01_REGE1686_04_GE_FM.indd 18 17/11/16 3:27 PM


Contents 19

Files and File Objects 414


Reading a File with a Scanner 417
6.2 Details of Token-Based Processing 422
Structure of Files and Consuming Input 424
Scanner Parameters 429
Paths and Directories 430
A More Complex Input File 433
6.3 Line-Based Processing 435
String Scanners and Line/Token Combinations 436
6.4 Advanced File Processing 441
Output Files with PrintStream 441
Guaranteeing That Files Can Be Read 446
6.5 Case Study: Zip Code Lookup 449

Chapter 7 Arrays 469


7.1 Array Basics 470
Constructing and Traversing an Array 470
Accessing an Array 474
A Complete Array Program 477
Random Access 481
Arrays and Methods 484
The For-Each Loop 487
Initializing Arrays 489
The Arrays Class 490
7.2 Array-Traversal Algorithms 491
Printing an Array 492
Searching and Replacing 494
Testing for Equality 497
Reversing an Array 498
String Traversal Algorithms 503
Functional Approach 504
7.3 Reference Semantics 505
Multiple Objects 507
7.4 Advanced Array Techniques 510
Shifting Values in an Array 510
Arrays of Objects 514
Command-Line Arguments 516
Nested Loop Algorithms 516

A01_REGE1686_04_GE_FM.indd 19 17/11/16 3:27 PM


20 Contents

7.5 Multidimensional Arrays 518


Rectangular Two-Dimensional Arrays 518
Jagged Arrays 520

7.6 Arrays of Pixels 525

7.7 Case Study: Benford’s Law 530


Tallying Values 531
Completing the Program 535

Chapter 8 Classes 556


8.1 Object-Oriented Programming 557
Classes and Objects 558
Point Objects 560

8.2 Object State and Behavior 561


Object State: Fields 562
Object Behavior: Methods 564
The Implicit Parameter 567
Mutators and Accessors 569
The toString Method 571

8.3 Object Initialization: Constructors 573


The Keyword this 578
Multiple Constructors 580

8.4 Encapsulation  581


Private Fields 582
Class Invariants 588
Changing Internal Implementations 592

8.5 Case Study: Designing a Stock Class 594


Object-Oriented Design Heuristics 595
Stock Fields and Method Headers 597
Stock Method and Constructor Implementation 599

Chapter 9 Inheritance and Interfaces 613


9.1 Inheritance Basics 614
Nonprogramming Hierarchies 615
Extending a Class 617
Overriding Methods 621

A01_REGE1686_04_GE_FM.indd 20 17/11/16 3:27 PM


Contents 21

9.2 Interacting with the Superclass 623


Calling Overridden Methods 623
Accessing Inherited Fields 624
Calling a Superclass’s Constructor 626
DividendStock Behavior 628
The Object Class 630
The equals Method 631
The instanceof Keyword 634
9.3 Polymorphism 636
Polymorphism Mechanics 639
Interpreting Inheritance Code 641
Interpreting Complex Calls 643
9.4 Inheritance and Design 646
A Misuse of Inheritance 646
Is-a Versus Has-a Relationships 649
Graphics2D 650
9.5 Interfaces 652
An Interface for Shapes 653
Implementing an Interface 655
Benefits of Interfaces 658
9.6 Case Study: Financial Class Hierarchy 660
Designing the Classes 661
Redundant Implementation 665
Abstract Classes 668

Chapter 10 ArrayLists 688


10.1 ArrayLists 689
Basic ArrayList Operations 690
ArrayList Searching Methods 693
A Complete ArrayList Program 696
Adding to and Removing from an ArrayList 698
Using the For-Each Loop with ArrayLists 702
Wrapper Classes 703
10.2 The Comparable Interface 706
Natural Ordering and compareTo 708
Implementing the Comparable Interface 712
10.3 Case Study: Vocabulary Comparison 718
Some Efficiency Considerations 718
Version 1: Compute Vocabulary 721

A01_REGE1686_04_GE_FM.indd 21 17/11/16 3:27 PM


22 Contents

Version 2: Compute Overlap 724


Version 3: Complete Program 729

Chapter 11 Java Collections Framework 741


11.1 Lists 742
Collections 742
LinkedList versus ArrayList 743
Iterators 746
Abstract Data Types (ADTs) 750
LinkedList Case Study: Sieve 752

11.2 Sets 755


Set Concepts 756
TreeSet versus HashSet 758
Set Operations 759
Set Case Study: Lottery 761

11.3 Maps 763


Basic Map Operations 764
Map Views (keySet and values) 766
TreeMap versus HashMap 767
Map Case Study: WordCount 768
Collection Overview 771

Chapter 12 Recursion 780


12.1 Thinking Recursively 781
A Nonprogramming Example 781
An Iterative Solution Converted to Recursion 784
Structure of Recursive Solutions 786

12.2 A Better Example of Recursion 788


Mechanics of Recursion 790

12.3 Recursive Functions and Data 798


Integer Exponentiation 798
Greatest Common Divisor 801
Directory Crawler 807
Helper Methods 811

12.4 Recursive Graphics 814

A01_REGE1686_04_GE_FM.indd 22 17/11/16 3:27 PM


Contents 23

12.5 Recursive Backtracking 818


A Simple Example: Traveling North/East 819
8 Queens Puzzle 824
Solving Sudoku Puzzles 831

12.6 Case Study: Prefix Evaluator 835


Infix, Prefix, and Postfix Notation 835
Evaluating Prefix Expressions 836
Complete Program 839

Chapter 13 Searching and Sorting 858


13.1 Searching and Sorting in the Java Class Libraries 859
Binary Search 860
Sorting 863
Shuffling 864
Custom Ordering with Comparators 865
13.2 Program Complexity 869
Empirical Analysis 870
Complexity Classes 876
13.3 Implementing Searching and Sorting Algorithms 878
Sequential Search 879
Binary Search 880
Recursive Binary Search 883
Searching Objects 886
Selection Sort 877
13.4 Case Study: Implementing Merge Sort 890
Splitting and Merging Arrays 891
Recursive Merge Sort 894
Complete Program 897

Chapter 14 Stacks and Queues 910


14.1 Stack/Queue Basics 911
Stack Concepts 911
Queue Concepts 914
14.2 Common Stack/Queue Operations 915
Transferring Between Stacks and Queues 917
Sum of a Queue 918
Sum of a Stack 919

A01_REGE1686_04_GE_FM.indd 23 17/11/16 3:27 PM


24 Contents

14.3 Complex Stack/Queue Operations 922


Removing Values from a Queue 922
Comparing Two Stacks for Similarity 924
14.4 Case Study: Expression Evaluator 926
Splitting into Tokens 927
The Evaluator 932

Chapter 15 Implementing a Collection Class 948


15.1 Simple ArrayIntList 949
Adding and Printing 949
Thinking about Encapsulation 955
Dealing with the Middle of the List 956
Another Constructor and a Constant 961
Preconditions and Postconditions 962
15.2 A More Complete ArrayIntList 966
Throwing Exceptions 966
Convenience Methods 969
15.3 Advanced Features 972
Resizing When Necessary 972
Adding an Iterator 974
15.4 ArrayList<E> 980

Chapter 16 Linked Lists 991


16.1 Working with Nodes 992
Constructing a List 993
List Basics 995
Manipulating Nodes 998
Traversing a List 1001
16.2 A Linked List Class 1005
Simple LinkedIntList 1005
Appending add 1007
The Middle of the List 1011
16.3 A Complex List Operation 1018
Inchworm Approach 1023
16.4 An IntList Interface 1024

A01_REGE1686_04_GE_FM.indd 24 17/11/16 3:27 PM


Contents 25

16.5 LinkedList<E> 1027


Linked List Variations 1028
Linked List Iterators 1031
Other Code Details 1033

Chapter 17 Binary Trees 1043


17.1 Binary Tree Basics 1044
Node and Tree Classes 1047

17.2 Tree Traversals 1048


Constructing and Viewing a Tree 1054

17.3 Common Tree Operations 1063


Sum of a Tree 1063
Counting Levels 1064
Counting Leaves 1066

17.4 Binary Search Trees 1067


The Binary Search Tree Property 1068
Building a Binary Search Tree 1070
The Pattern x = change(x) 1074
Searching the Tree 1077
Binary Search Tree Complexity 1081

17.5 SearchTree<E> 1082

Chapter 18 Advanced Data Structures 1097

18.1 Hashing 1098


Array Set Implementations 1098
Hash Functions and Hash Tables 1099
Collisions 1101
Rehashing 1106
Hashing Non-Integer Data 1109
Hash Map Implementation 1112

18.2 Priority Queues and Heaps 1113


Priority Queues 1113
Introduction to Heaps 1115
Removing from a Heap 1117
Adding to a Heap 1118
Array Heap Implementation 1120
Heap Sort 1124

A01_REGE1686_04_GE_FM.indd 25 17/11/16 3:27 PM


Random documents with unrelated
content Scribd suggests to you:
Northumberland and of Lieutenant Frye of the Marines had no doubt
their share in bringing about this change.
The most famous of the alterations made in 1749 was that inserted
in the 12th and 13th articles of the Articles of War which were
incorporated in the Act. The 12th article provides the punishment to
be inflicted “on Every Person in the Fleet who through Cowardice,
Negligence, or Disaffection, shall in Time of Action withdraw or hold
back, or not come into the fight or Engagement, or shall not do his
utmost to take or destroy every ship which it shall be his Duty to
engage, and to assist and relieve all and every of his Majesty’s Ships
or those of his Allies which it shall be his duty to assist and relieve.”
The 13th Article deals with him who hangs back in chase or does not
“relieve or assist a known Friend in View to the utmost of his Power.”
Originally the court had a discretion, but by the terms of the new Act
the only punishment a court martial could inflict was death. At a
later period the severity of this penalty was considered excessive,
and in 1779 the power to inflict a lesser penalty was restored to the
court martial, but in 1749 Parliament had just heard from the mouth
of Vernon that the savage punishment of poor young Baker Philipps
was just, and it knew how austere the court had been with humble
James Dixon, the master of the Northumberland. It also knew what
bowels of compassion had been found for the captains of Toulon and
for Lestock and Mitchell. If Parliament was resolved that what was
law for obscure and friendless men should also be law for the chiefs
of the navy, it may have been stern but it was not unjust. The Bill
was introduced by ministers who had the advice of Anson, and we
may fairly conclude that he did not disapprove of the change.
From 1748 to 1756 the country remained at peace, but it was of the
kind compatible with continuous “military operations.” Both in the
East Indies and on the continent of North America and among the
islands of the West Indies, the British Government of that time had
to deal with a more violent version of what we have seen happen in
our day in the valleys of the Nile and the Congo. The main outlines
of the struggle were given at the beginning of the last chapter. On
the frontier of Nova Scotia the two states were in peculiar contact of
irritation. The frontier had never been clearly marked, and the
French strove to delimit it in their own favour by a characteristic
mixture of pertinacious diplomatic pettifogging and violence. In the
East the intrigues of Dupleix with the native princes of the Carnatic
aimed at ruining the commerce of the English company by cutting
off the establishments on the coast of Coromandel from access to
the interior. On the continent of America the seventy thousand or so
French in Canada and Louisiana were incessantly endeavouring, not
only to recover the greater part of Nova Scotia, but to bar the million
and a half of English settlers from access to the valleys of the Ohio
and the Mississippi. Resolute action on the part of the British
Government would probably have averted war, but the Duke of
Newcastle, who was the prevailing politician of the day, was intent
on Parliamentary management. The king too was rendered nervous
by fears for his hereditary dominions in Hanover. From sheer want of
vigorous direction on our own part we drifted, through a succession
of small conflicts, into open though unavowed war in 1755, and into
formally declared war in 1756. The situation was that of 1739, with
differences. Then we had begun with the Spaniards, and had only
come into collision with the French later on. Spain, in this case, did
not intervene till the very close, and in an hour of folly. Once again,
too, France became entangled in a great European land war, and
was unable to devote her whole attention to the sea. We engaged in
the land war as allies of Frederick of Prussia and in defence of
Hanover, but our main attention was devoted to the sea and to our
colonies.
The first serious hostile movement made by the British Government
was directed towards the East. The India Company had soon
occasion to regret that it had parted so easily with Boscawen’s
squadron. In 1753 it was calling on the Government for naval help,
and in February 1755 a squadron was despatched under the
command of Rear-Admiral Charles Watson. It was delayed at Kinsale
by a storm, and two vessels were seriously damaged. They were
replaced, and Watson reached Bombay in November with four sail of
the line, and two small vessels. He brought a reinforcement of
troops and Colonel Clive. His first piece of service was not against
the French. The Royal Navy was now beginning to take permanent
hold on the Eastern seas. No more pressing duty awaited it than to
put a stop to piracy. This had always flourished on the western or
Malabar coast of India, and had never been effectually checked by
the Portuguese, the Dutch, or by ourselves. By far the most
formidable of these pirates belonged to a branch of the Mahrattas,
which had gained possession of the island of Geriah, had become
independent, and had transferred its native practice of robbery from
the land to the sea. These pirate Mahrattas infested the coast in
vessels called “grabs” and “gallivats”—the first a species of
magnified lighter armed with guns, the second light rowing and
sailing galleys. Sporadic attacks had been made on them by the
company, and by occasional ships of the Royal Navy. Mathews had
served against them. But hitherto nothing effectual had been done.
In 1755 the presence of a well-appointed squadron and of a
disposable body of troops encouraged the company’s agents at
Bombay to make an effort to root out the pirates of Geriah. On the
7th of February 1756 Watson sailed from Bombay, carrying the
soldiers under command of Clive with him, and in co-operation with
a body of Mahratta troops supplied by one of the princes of that
nation, who wished to reduce Angria, the chief of the pirate state, to
obedience. They proved to be of little value, for they were chiefly
intent on plunder, and had secretly more sympathy with their
piratical kinsmen than with their allies. Angria showed little spirit.
The vigour of Admiral Watson who battered down the fortifications
of Geriah on the 12th February, and the firmness of Clive who took
possession of the place, disappointed the Mahrattas. Our squadron
and the troops divided £150,000 of prize money.
On the 30th April Watson and Clive went on from the coast of
Malabar to that of Coromandel on the east. By the 20th June they
reached Madras. The French Government, not being as yet ready for
war, had recalled Dupleix and had brought a pause in the conflict of
the companies. Watson’s next service was to carry Clive to Bengal to
revenge the Black Hole of Calcutta, and to begin the conquest of
India. But as this service became rapidly connected with the war
against France, and as the operations in the eastern seas lay very
much apart, I shall turn from them till they can be taken up again,
and connected with the general movements of the world-wide
conflict.
While Admiral Watson’s squadron was recruiting from its long voyage
at Bombay, warlike operations, the forerunners of open war, were
beginning on the Atlantic. The appeals of the colonists who found
themselves unable to expel the French from the post they had
established on the Ohio—Fort Duquesne on the site of what is now
Pittsburg—had at last induced the British Government to take action.
In December 1754 Commodore Keppel, a gentleman of the
Albemarle family, who had sailed as midshipman with Anson and
was destined to play a prominent part in coming years, left the
Downs with a body of troops under command of Braddock. The
expedition reached Hampton Roads by the 20th February 1755. Its
disastrous end, in an ill-planned and worse-directed attack on Fort
Duquesne in July of this year, is a well-known episode of our colonial
history. The sending of Braddock stimulated the French Government
to reinforce its garrisons in Canada. On the 3rd May of 1755 the
Lieutenant-General Count de Macnémara sailed from Brest with nine
sail of the line fully armed and seven frigates. He had under his
protection eleven sail of the line fitted as transports and full of
troops. These vessels were armed with 24 or 22 guns only, or as the
French expression has it, en flûte. To be armed en flûte was to be
armed like a flyboat with guns only on the upper deck. Macnémara
saw his charge well out into the ocean, and then returned to Brest
with six of the liners and three of the frigates. The other warships
and the transports held on to Canada under the command of Dubois
de Lamotte.
Meanwhile the news that the French were in motion stirred the
British Government to counter action. Boscawen was ordered to sail
for America with instructions to intercept the French by force. He left
on the 27th April, with eleven sail of the line, and two small vessels.
After he had gone the cabinet received further reports which gave
them an exaggerated idea of the French strength. Admiral Holburne
was ordered to follow Boscawen with six sail of the line, and a
frigate. He left on the 11th May, and joined his chief on the banks of
Newfoundland on the 20th June. But Boscawen had already failed to
stop the French. When Dubois de Lamotte approached
Newfoundland he divided his squadron and convoy into two. One
division was steered to enter St. Lawrence by the Straits of Belleisle,
on the north of Newfoundland. The other took the commonly used
route to the south between Cape Ray and Cape Breton. Boscawen
had stationed himself off Cape Ray. On the 9th June the French were
sighted, but the weather was foggy and covered them soon from
view. Next day the fog lifted for a space, and three of the French
ships were seen. They were the Alcide, 64, the Lys, armed en flûte
with 22 guns, and the Dauphin Royal, another of the man-of-war
transports. The Alcide was commanded by M. d’Hocquart who had
already been twice prisoner of war to Boscawen. In 1744, when he
was captain of the Medée, 26, he had been taken by the
Dreadnought. This was Boscawen’s first ship, and from it he got his
name of “Old Dreadnought” among the sailors. Again M. d’Hocquart
had struck to Boscawen in Anson’s battle of 3rd May 1747. When the
English officer commanded the Namur and he himself the Diamant,
M. d’Hocquart’s ill fortune pursued him. The Alcide was overhauled,
hailed by Howe in the Dunkirk, 60, and told to stop. The French
captain asked whether it was peace or war, and was told that he had
better prepare for war. D’Hocquart made all the defence he could,
but the Dunkirk was reinforced by Boscawen’s ship, the Torbay, 74,
and he became a prisoner for the third time. The Lys was taken by
the Defiance, and the Fougueux. The Dauphin Royal escaped in the
fog. No other prizes were taken, so that Dubois de Lamotte carried
two fully armed liners, three frigates, and ten transports with their
men and stores safe into the French American ports. Boscawen’s
expedition was therefore, in the main, a failure. The jail fever was
raging in his squadron. It had been manned, according to old
custom, in haste on the approach of war, by the press, from the
slums and the prisons. Boscawen took his ships to Halifax in the
hope of restoring the health of his crews, but with the result that he
infected the town. Meanwhile the French commanders, finding the
coast clear, sailed for home on the 15th August and reached Brest
on the 21st September. Boscawen returned in the autumn, reaching
England in November.
While fighting had begun in America we were at home in a state of
war which was no war. The Duke of Newcastle was driven by dread
of unpopularity to appear to do something. The country, thoroughly
persuaded that the time had come when it must make the decisive
fight for its trade and colonies, was burning for war. But continental
complications, and above all his own vacillating timid character,
made Newcastle shrink from vigorous action. There was indeed an
immense bustle of preparation. Ships were ordered into commission
by the score from the beginning of the year, and the work of putting
the fleet on a war footing was accompanied by the inseparable
offers of bounty and press-warrants. On the 23rd January 1755
there came out one proclamation offering a bounty of thirty shillings
to every able seaman between twenty and fifty years of age who
would volunteer, and twenty shillings to every ordinary seaman. On
the 8th February another followed recalling all seamen serving
abroad, and raising the bounties to £3 and £2, while the common
informer was stimulated by rewards of £2 to whomsoever would tell
where an able seaman was in hiding, and of £1, 10s. to the betrayer
of an ordinary. A hot press went on in all the ports. The war was a
merchants’ war, and the traders of London and the outports offered
bounties in addition to those given by the state. By this combination
of persuasion and force the fleet was manned after a fashion. Yet
the mere fact that the competition for men sent up the wages of
merchant seamen by leaps and bounds made the work of filling up
the warships very difficult. It was necessary to have recourse to the
prisoners in the jails, who were allowed to volunteer into the navy,
or were sent there as punishment. Parliament suspended the
provisions of the Navigation Laws, which limited the number of
foreigners who could serve in a British ship to one-fourth. It even
tempted them to serve under our flag by allowing them to obtain
letters of naturalisation at the end of two years, instead of the usual
limit of eight. By this act the Crown was empowered to suspend the
manning clauses of the Navigation Laws whenever war should break
out in future.
The dire need for men led to the adoption of two measures, one of
private enterprise, which did good work in its time, one
administrative of which we feel the benefit to this day. In 1756 was
founded the Marine Society. This body was formed to take charge of
destitute boys, whom it fed, clothed, and sent into the navy, where
they were trained as seamen. The spring of 1755 is a notable epoch
in the history of the Royal Navy, for it saw the foundation of the
present corps of Marines. The regiments raised hitherto had always
been “disbanded” or “broken” at the end of the wars. They had
never held a properly settled position, and there had been a
constant tendency to rob the force of its best men by rating them as
able seamen so soon as they had been long enough at sea to learn
the business. At the end of the War of the Austrian Succession the
Duke of Cumberland had recommended the formation of a
permanent military corps to be placed entirely under the authority of
the Admiralty. Nothing, however, was done till the 3rd April 1755,
when the Lords Justices, who governed during the absence of the
king in Hanover, issued a warrant authorising the formation of fifty
companies of one hundred men each, which were to have their
headquarters at Chatham, Portsmouth, and Plymouth. The value of
the Marines (the title Royal was not granted till 1802) was rapidly
demonstrated, and their numbers were increased. Thirty companies
were added before the end of 1755. Twenty more were ordered to
be raised in July 1756, and another thirty in March 1757. Two years
later, on 3rd March 1759, one lieutenant, one corporal, one
drummer, and twenty-three privates were added to every company.
By the end of the war the total strength of the force was 18,000.
All this stress of preparation was presided over by mere infirmity of
will. In July the Ministry, still guided by Newcastle, sent Sir Edward
Hawke to sea with twenty-one sail of the line, but with no definite
orders to begin hostilities. He was told to intercept a French
squadron from the West Indies and to capture French merchant
ships. The squadron put into Cadiz, got warning which enabled it to
avoid the English fleet, and reached Brest safely. But 300 merchant
ships manned by 8000 men were taken, and carried into our ports.
This seizure of trading ships in a time of nominal peace gave the
French Government an opportunity to denounce us to Europe as
pirates. Many Englishmen thought it would have been more for our
honour to make war openly, since we were about making it at all.
Yet the French had little right to complain after the example they
had set in India and America. The vessels were not condemned as
prize, and as they were largely loaded with fish their cargoes rotted,
so that it was necessary to tow them out to sea and sink them.
Hawke returned to port, ill pleased with the work he had been set to
do, and was replaced in the Channel command by Admiral Byng.
Then Byng was sent out to convince the country that something was
being done. He took a French line-of-battle ship, the Esperance, but
still war was not proclaimed. The French Government professed a
wish to keep the peace. Yet at the end of 1755 and the beginning of
1756 it marched troops down to the Channel. As the Duke of
Newcastle had succeeded for a time in infecting the nation with his
own cowardice, we were thrown into an unutterably shameful panic
by fear of invasion, though we had a powerful fleet in commission at
home, and the French had not the means of fitting out a dozen ships
at Brest. Under cover of this diversion the French invaded Minorca in
April. Then at last the Government was brought to confess that war
was war. Our proclamation appeared on the 17th May, and was
answered by the French on the 9th of June.
The panic of the country in the early months of 1756 was to some
extent justified. Yet its underlying belief, that if it could only find a
man to rule it had the strength to assert its maritime and colonial
supremacy, was well founded. In point of mere material force the
navy was far superior to the French. At the beginning of 1756 we
had, including the 50-gun ships which were still counted as fit to lie
in a line of battle, 142 liners. The smaller vessels were 125, taking
frigates and sloops together. When the bombs, fireships, and other
craft such as hospital ships were included, the total was 320. The
quality of our vessels, though still not all it ought to have been, had
improved greatly under the new establishment of 1745. The
discipline of the navy had bettered with the vessels. Some of the old
leaven still remained, and in one respect much was left to be done.
We had yet to learn how shameful it was that a fine squadron should
be paralysed by disease as Boscawen’s had been. But we were on
the right path. The intellect of the navy was awake, and was
beginning to apply itself to improving its armament and its discipline.
There was as yet no revolt against the Fighting Orders.
Want of numbers was the least of the evils which weighed on our
enemy. In 1754 the navy of France included only 60 line-of-battle
ships. Of these, 8 were in need of thorough repair, and 4 were still in
the stocks. During the brief administration of M. de Rouille efforts
were made to reinforce this list. Fifteen new line-of-battle ships were
launched by 1756. We may suppose that they included the vessels
building in 1754. If the eight in need of repair were thoroughly
overhauled by the same date, this would give France 71 line-of-
battle ships. But the French did not include the 50-gun ships, of
which they had 10, in the list, and they had therefore about 81
vessels to oppose to our 142. Of ships of 20 to 44 guns they had
only some 40 to oppose to our 83. Their navy was therefore about
one-half as numerous as ours. It must be remembered that at this
time France still held Canada and important stations on the coast of
Coromandel. She was under the same obligations as ourselves to
scatter her forces all over the world, and that with the prospect of
being everywhere outnumbered. With such a task to overcome, the
French had need of the very highest efficiency in every branch of the
naval service. But their navy had as much to seek in quality as in
quantity. The corrupt and careless government of Louis xv. had
allowed the storehouses to become nearly empty. During the years
of peace no attempt had been made to give the officers practice. In
1756 it was calculated that of 914 officers 700 had nothing to do
except mount guard for twenty-four hours in the dockyards eight or
ten times a year. The old feud between the Pen and the Sword—that
is, the civil and military branches of the navy—raged furiously. On
the ships there was mutual hostility between the officers of the
regular corps and the supplementary officers taken in on the
outbreak of war, and known as officiers bleus. None of the
corporations of the old French monarchy was more aristocratic or
more jealous than the Corps de la marine. The so-called despotic
King of France had far less power of choosing his officers than the
constitutional King of Great Britain. M. de Rouille endeavoured to
revive the professional spirit of the officers, dulled by years of
dawdling about the dockyards, by establishing the Académie de la
marine, with the well-known writer on tactics, Bigot de Morogue, as
its first head. But it was years before this could bear fruit, and
France began the Seven Years’ War with all the conditions internal
and external against her. How came it, then, that her navy was not
mewed up in port at once? The answer is easy. Because the British
Navy had its arms tied behind its back by the incapacity of the men
who ruled, till Pitt freed it.
The first great operation of the war was conducted under a fatal
combination of administrative stupidity in London and of the old
leaven in the fleet. Reports that the French were preparing a
powerful squadron at Toulon began to reach England before the end
of 1755. The orders to prepare had been given in August, but in the
destitution of the French dockyards eight months passed before it
was ready. The boasted classes failed to produce men, and the
French were driven to offers of bounty, and to attempts to recruit
Italian sailors at Genoa. It was long before the urgent
representations of our Consul at Genoa, and of General Blakeney at
Minorca, could make the Ministry see that the island was in danger.
Blakeney was a gallant old Anglo-Irishman born in 1672, who had
fought against the Rapparees in 1690, and served under King
William and Marlborough, had been at Carthagena with Vernon, and
had defended Stirling Castle against the Jacobites in the ’45. He
commanded the place, though bedridden with gout, in the absence
of Lord Tyrawley the Governor, who according to the easy practice of
the day drew his salary at home. It was not less characteristic of the
time that many officers of this threatened garrison were absent on
leave when the French invaded the island.
Richelieu landed with 14,000 men at Ciudadela on the 19th April.
After many delays and much confusion, the Ministry had at last been
brought to see that Minorca was in danger, and a squadron of ten
ships had sailed to relieve it on the 6th April. The command of the
squadron was given to an officer whose name has a tragic interest
unique in the long list of British admirals. John Byng was the fourth
son of that George Byng, Viscount Torrington, whose active
subordinate share in the Revolution of 1688, and command in the
Mediterranean in 1718, have been already mentioned. The son was
born in 1704, and had gone to sea at the age of thirteen. He served
under his father at the battle of Cape Passaro, and became post-
captain at the age of twenty-three. He had gained no distinction, nor
had he sought any, on those remote unhealthy stations where the
most arduous work of the navy was being done. His portrait is that
of a handsome, refined, but plump and easy-going young man, and
compares ill with his father’s. George Byng has the lean, eager face
of one who though of gentle birth had to climb by his own efforts.
John Byng has the air of one whose father was born before him, and
who did not rise, but was carried up with no effort of his own by the
fortune another had made. He had sat in Parliament, and had not
escaped the corrupting influence of the factious, selfish, jobbing
spirit of the political world of his generation.
Byng was selected to carry the reliefs to Minorca on the 11th March,
but nearly a month passed before he sailed. Though we had a great
fleet commissioned and commissioning, much difficulty was found in
manning the ten ships assigned him for the service. The Admiralty
refused to draft men from well-manned vessels on the ground that
they were needed at home. Some part of the blame for this must be
put on Anson and Boscawen, who were on the Board. The great
responsibility lay on the mere politicians and borough-mongers
whose folly was paralysing the strength of England, but it must be
confessed that Anson in dealing with political chiefs and colleagues
did not show the courage he had never failed to display in fighting
the storm or the broadsides of the enemy. As Byng was to reinforce
the garrison of Minorca, he carried with him both the officers who
were at home on leave and Lord Robert Bertie’s regiment of foot. By
a piece of blundering, for which Anson cannot be held blameless, the
marines were landed to make room for the soldiers. If now they
were landed in Minorca, the squadron, already ill manned, would
have been dangerously weakened. As the French were known to
have a fleet at sea, Byng was thus put at a serious disadvantage,
and an angry sense of ill-treatment rankled in his mind, not
unnaturally, but fatally, for it had a share in causing him to adopt a
line of conduct which brought discredit to his country and a
shameful death to himself. It never occurred to him that if he beat
the enemy’s fleet soundly he could safely land the soldiers who had
taken the place of his marines.
His orders were dated the 1st April. He was told to sail to the Straits
of Gibraltar. If on arriving there he heard that the French had sent
vessels into the Atlantic bound for America, he was to detach part of
his squadron under his second in command, Rear-Admiral Temple
West, to follow them, and proceed with the remainder to Minorca. If
he found that the island was being attacked, he was to render what
help he could, and if not, then to blockade Toulon. There is a certain
futility in these orders, for they take no notice of the contingency
that even if Byng was able to beat off the French warships, or found
none to fight, the relief he brought might not be sufficient to enable
Blakeney to resist the troops already landed under Richelieu. But he
would do much if he could cut the French off from Toulon, and
however feeble the measures of ministers may have been, it was not
the less his duty to do his utmost. Byng, unhappily for himself, and
for us, drew the strange deduction, that since he was not supplied
with the means of relieving the garrison altogether, he was justified
in making a feeble use of his ships. Orders were also sent to General
Fowke, who was in command at Gibraltar, to spare a part of his
garrison for Minorca if he felt that he could part with them safely.
The voyage out to Gibraltar was tedious. It was not till the 2nd May
that Byng reached the Rock, where he was joined by Commodore
Edgcumbe with the Princess Louisa, 60, and the Fortune sloop, part of
a small squadron which had been cruising in the neighbourhood of
Minorca when it was invaded. The Deptford, 50, and the Portland,
50, joined shortly afterwards. At Gibraltar Byng also heard of the
landing of the French, of their strength, and of the distressed
position of the English garrison shut up in Fort St. Philip, at the
mouth of Mahon Harbour. On the 4th May he sent off a dispatch
which is of extreme importance as illustrating the state of mind he
was in, and as explaining his conduct. In it he says:—
“If I had been so happy as to have arrived at Mahon
before the French had landed, I flatter myself I would
have been able to have prevented their setting foot on
that island; but, as it has so unfortunately turned out, I
am firmly of opinion, from the great force they have
landed, and the quantity of provisions, stores and
ammunition of all kinds they have brought with them, that
the throwing men into the castle, will only enable it to
hold out a little longer time, and add to the number that
must fall into the enemy’s hands; for the garrison in time
will be obliged to surrender, unless a sufficient number of
men could be landed to dislodge the French or raise the
siege.”
After thus declaring that all efforts must be useless, he promised to
go on to Minorca to do what he could, and in case it should turn out
to be nothing, then he would return to Gibraltar to cover that place.
This letter, which was sent home overland, gives the measure of the
man. It may be compared with the letter which Herbert had sent up
to London on first sighting Tourville’s fleet off the Isle of Wight in
1690. Both men were plainly under the influence of a mischievous
delight on contemplating the embarrassment which a national
disaster would be likely to bring on the ministers who had sent them
out with insufficient fleets. Herbert had the excuse that he was in
the presence of a much superior force. Byng makes no mention of
inability to fight the French fleet. He was prepared to retire without a
battle if he could not get security that the French troops would also
be driven off by the reinforcement he had brought, and this he had
already declared to be impossible. In the same letter he speaks of
the chance that the French would come on to Gibraltar when they
had got all the vessels ready they possibly could. He neither
contemplated the possibility of attempting to beat them in detail
before they were all ready, nor the effect likely to be produced on
Richelieu if his communications with France were cut. Yet a strong
fort open to relief from the sea might have made a prolonged
defence, and could have given time for further reinforcements from
England. When they arrived, the total surrender of the French would
be inevitable. It was natural that when this letter reached England
the Ministry concluded that Byng did not mean to exert himself to
relieve Minorca, and that foreseeing a disaster, they took measures
to turn popular rage against the admiral. They would have been
more than human if they had not, and Byng was a foolish man
indeed if he did not know that they were very basely human.
The squadron, now increased from ten to thirteen sail, left Gibraltar
on the 8th May. General Fowke, with a weakness equal to Byng’s,
declined to part with more than 250 men. There had been councils
and confabulations of weak men, all ending in agreement that the
enterprise was hopeless. So Byng reluctantly approached “the post
of the foe.” On the 19th he was in sight of Minorca at the south-
easterly point where St. Philip stands at the mouth of the long land-
locked harbour of Mahon. The French fleet was not then in sight.
The Phœnix frigate commanded by Captain Hervey, with the
Chesterfield and Dolphin, were sent on ahead with the officers
belonging to the garrison, and orders to communicate with General
Blakeney. Before they could reach the harbour mouth the French
fleet was sighted to the south-east, and Byng recalled the frigates. It
was an unnecessary measure, due to excess of caution, for the
frigates were not indispensable to the fighting power of the fleet,
and the military officers they carried would have been of great value
to the garrison.
The rest of the day passed in manœuvres, and without a battle.
Byng’s squadron was outsailed, but he showed no zeal to force on
an action, and confined himself to endeavouring to remain to
windward. During the night the fleets parted, and at daybreak were
not in sight of one another. They were from 30 to 40 miles off the
island. It was hazy, but cleared up about ten, when the enemy was
seen a long way off to the south-east. The wind was from the south-
west. By midday the two fleets were approaching one another, both
close hauled, the French on the port, the English on the starboard
tack, in two lines forming an obtuse angle. About one we weathered
the head of the French line, and Byng afterwards boasted of having
gained the weather-gage. If he did it by fair sailing, his ships cannot
have been so inferior in quality to the enemy as he pleaded they
were when he had to excuse himself. As the French habitually
preferred to engage to leeward, which left their line of retreat open,
it is probable that he attributed to his own skill what was the
deliberate act of the enemy. About two o’clock the English had
passed to windward, and to the south of La Galissonière, our last
vessel being nearly abreast of his first. We were thirteen of the line,
and the French twelve. Being now in the position to force on a
battle, Byng brought his fleet round, all ships turning together, so
that we headed in the same general direction as the French, and
ordered the Deptford to leave the line so that we might be ship to
ship with the enemy. It was a strange action in an admiral who
complained bitterly of the inferiority of his fleet, but was doubtless
due to mere pedantry. Byng, who was a martinet in the fopperies of
his profession, had no idea of fighting a battle except by the
orthodox pattern, van to van, centre to centre, rear to rear, and
having one ship more than his opponent, did not know what to do
with her. Here are the two fleets in the order in which they engaged:

English
Defiance 60 Capt. Andrews.
Portland 50 〃 Baird.
Lancaster 60 〃 Edgcumbe.
Buckingham (flagship of Admiral West) 68 〃 Everitt.
Captain 64 〃 Catford.
Intrepid 64 〃 Young.
Revenge 64 〃 Cornwall.
Princess Louisa 60 〃 Noel.
Trident 64 〃 Durell.
Ramillies (flagship of of Byng) 90 〃 Gardiner.
Culloden 74 〃 Ward.
Kingston 60 〃 Parry.
French
Lion 64 Capt. de Saint-Aignan.
Triton 64 Capt. de Mercier.
Redoutable (flagship of Commodore de
74 Capt. de Vilarzel.
Glandèvez)
Orphée 64 Capt. de Raymondis.
Fier 50 Capt. d’Herville.
Guerrier 74 Capt. Villars de Labrosse.
Foudroyant (flagship of La Galissonière) 80 Capt. Froger de l’Eguille.
de Beaumont
Téméraire 74 Capt.
Lemaître.
Hippopotame 50 Capt. Rochemore.
de Sabran
Content 64 Capt.
Grammont.
Couronne (flagship of Commodore La Clue) 74 Capt. Gabanous.
Sage 64 Capt. Durevest.
When the order to engage was given, the fleets were not parallel,
but on lines converging to form an acute angle ahead of them. Thus
the leading English ship was nearer the leading ship of the French
than the rear was to their rear. So if each bore down on the
Frenchman opposite to it at the time, the vessels in the van would
come into action first, and would be exposed to a converging fire,
while it would depend on the enemy’s decision to stay still and be
attacked, whether the centre and rear of the English fleet ever got
into action at all.
Admiral West came down on the Frenchmen briskly, and then hauled
up with the heads of his ships in the same direction as theirs.
Meanwhile the other English vessels were steering to come into
action while carefully preserving their relative positions to the
vessels in the van. In the French line vessels here and there stood
out, and ran to leeward. Our men cheered, thinking they had forced
the enemy to flee, but the movement was the result of design. As
these vessels ran to leeward, those astern “let all draw” and shot
ahead. Thus a movement in advance was given to the whole French
line, and the distance which the English ships of the centre and rear
had to cover before reaching their proper opponents was constantly
increased. In any case, the French admiral would almost certainly
have succeeded in filing past the leading English vessels, crippling
their rigging, and then running down to form a new line to leeward.
But he was helped by a piece of bungling in our squadron. The
Intrepid, the sixth ship, lost her foretop-mast. As she was before the
wind, this ought to have been no great disaster, but she was so
badly steered that she came right round and lay across the path of
the following ship—the Revenge. According to all rule, tradition, and
honour, the Revenge ought to have passed between the crippled
Intrepid and the enemy—that is to leeward. But she tried to pass to
windward, could not do so, and then backed her topsail to stop her
way and prevent a collision. The vessels behind did the same thing,
and thus our fleet broke in two. The five ships ahead of the Intrepid
followed the enemy with Admiral West, while the others remained
behind. It was about this time that the flag-captain, Gardiner,
pointed out to Byng that if he stood out of his line he could bring the
Frenchman then running past him to closer action. The admiral
answered that Mathews had been broken for not taking his fleet
down in a body, and that he would not incur the same fate. Rather
than offend against the superstition of the line of battle, he would let
the enemy get off unhurt. La Galissonière did get off with little
damage, leaving us with three ships badly crippled in their rigging,
and the whole fleet in scandalous disorder.
So ended the battle of the 20th May. It was first and foremost an
example of what must happen so long as our navy continued to be
bound by the stupid pattern set up in the Fighting Instructions for all
actions against an enemy of equal, or approximately equal, force—
so long, in fact, as we continued to engage to windward, ship to
ship, leaving the enemy his line of retreat open, and depriving
ourselves of the power to push the attack home, by making it a rule
to adhere to the formation in which we began the fight. In these
conditions decisive results were not to be achieved. But Byng did ill
even according to this stupid model. He ought to have arranged his
fleet parallel to the enemy before he bore down, and he ought not
to have begun firing, as he did, when at such a distance that he
could do no harm. Yet the lame and impotent conclusion of the
battle and his own bungling might both have been forgiven, or even
passed unnoticed, but for what followed. The fleet was satisfied that
it had made the enemy run, and the nation would have been
satisfied too, if there had been any effort to help Fort St. Philip in the
days following the battle. There was none. For four days Byng
loitered near the scene of the action, repairing the vessels crippled
on the 20th. He said it was not easy to do, and indeed, from first to
last, showed a marked disinclination to attempt anything that was
not “easy.” Then a council of war came to the conclusion, which is
always so welcome to weak men weakly led, that nothing more
could be done. The fleet returned to “cover” Gibraltar, leaving
Minorca to its fate. Before the complacent dispatch in which Byng
announced his decision could reach home, the news of the failure
had been given by La Galissonière’s boastful letter to his own king. It
was published in Paris, and sent on from thence. In truth the French
admiral was very nervous, constantly expecting the reappearance of
the English in superior force, and was only kept from retiring to
Toulon by the incessant driving of Richelieu. The honour both of the
defence and of the attack in this campaign belongs wholly to the
soldiers. When the result of the meeting of the two fleets was
known, there burst out a storm of rage of which the echoes can be
heard to this day. It is not pleasant to hear a people howling for the
life of a man, whether he be the great and terrible Strafford or poor,
weak, self-satisfied John Byng. The manifestations, too, were vulgar.
The mob hanged the admiral in effigy, the City of London sent
deputations asking for his life, the Prime Minister gabbled promises
that he should be punished. Meanwhile Byng had returned to
Gibraltar on the 19th June. He found there a reinforcement of five
line-of-battle ships under Commodore Brodrick, who had arrived on
the 15th from England. Preparations were being made to return to
Mahon when Hawke came into Gibraltar to take command and also
to send Byng home for trial together with the witnesses. Fowke was
also recalled. The admiral heard of his supersession with unaffected,
or at any rate with remarkably well-simulated, indignation. He wrote
a furious self-laudatory letter on the 4th July, all but claiming a
statue for his exertions. On the 9th July he sailed a prisoner in the
Antelope, and reached England on the 19th August.
He was first imprisoned at Greenwich, and then sent to Portsmouth
for trial. In the sentimental reaction of coming years, it was said that
he could not expect fair treatment in the prevailing rage of the
nation, and that he was made a sacrifice by base-minded politicians.
But nobody can read the minutes of the court martial without seeing
that the admiral had a perfectly fair trial, and was condemned on his
merits, while the politicians who had an interest in securing his
condemnation had left office before the court martial began, and
remained out till after his execution. Newcastle had been replaced
by the first short administration of Pitt. The court martial began to
sit on the 17th December 1756, and sentence was given on the 28th
February 1757. The court found that the admiral had offended
against the 12th Article in that he had not done his utmost against
the enemy. Therefore, though it acquitted him of cowardice or
disaffection, it found him guilty of negligence, and condemned him
to the only punishment it was authorised to inflict, which was death.
Attempts were made to save his life. The House of Commons even
passed a Bill to relieve the officers forming the court martial from
the obligation to preserve secrecy as to what had passed in their
private decision on the sentence. It was hoped that they might have
something to say which would avail the prisoner, but when
questioned by the House of Lords they could answer nothing to the
purpose. The Upper House rejected the Bill, and the admiral was
shot to death on the deck of the Monarque on the 14th March 1757.
He died with dignity, and protesting to the last he had been made a
victim.
In the changes of things and in the usual reaction by which
Englishmen habitually atone for the fury of their rage, he came
indeed to be thought of as a victim, yet the sentence was just.
Coward, in the sense that he suffered from the pitiable cowardice
which makes a man sick and giddy at the approach of personal
danger, he was not. Neither was he disaffected, in the sense that he
was scheming to upset the Government he served. As these were
the forms of cowardice and disaffection contemplated by the Act, the
court very properly acquitted him under these heads. But he was a
coward in the intellectual sense. Having a dangerous piece of work
to do, and one in which the very errors of the Government rendered
it only the more incumbent on him to make all wants good by his
own exertions, he thought chiefly of doing it at the least risk, and
was resigned to failure. The excuses he made were pitiable. All
through he insisted on the inferiority of his fleet. Yet he had thirteen
ships to twelve. It is true that the French were better vessels, the
Foudroyant with her 80 guns, for instance, being superior in real
strength to the Ramillies with her 90. Yet the Foudroyant afterwards
surrendered to a much smaller ship than the Ramillies. He harped on
the lesser weight of his guns, and it is true that the 42-pounders
carried on the lower deck of some French ships were heavier than
any of ours. Yet he had 834 guns to the Frenchman’s 806, and the
42-pounder was afterwards rejected from our navy as too lumbering
for ship-work. All through he kept insisting on the risk of doing this
or that, till he brought upon himself the scathing answer of
Blakeney: “I have served these sixty-three years, and I never knew
any enterprise undertaken without some danger; and this might
have been effected with as little danger as any I ever knew.” It was
monstrous that men should think they could make war without
hazard. Therefore the court justly found Byng guilty of
“negligence,”—that is to say, all that deficiency to do enough, all that
hanging back from strenuous effort, which are due to want of spirit,
to a selfish regard of what the soft-minded man thinks are the
interests of his safety, to the moral cowardice which falls short of
mere physical poltroonery, and the disaffection which stops on this
side of deliberate treason. The law had been made stern after the
experience of the last war. Byng knew the conditions of his
servitude. They were in the Act by which he exercised his own
authority, and he sinned against the light.
Brutal as the wrath of the nation was, it was founded on a sound
sentiment. If England was to take her place in the world, there had
to be an end of Mathews and Lestock, of Peyton, Griffin, and
Cornelius Mitchell. Voltaire’s famous jest that the English shot an
admiral to encourage the others suffers from the worst defect a scoff
can have. He meant it for a reductio ad absurdum. It was a perfectly
accurate statement of fact. The shooting of Byng did encourage the
others. Henceforward there might be errors and stupidities, and
failures here and there. So there always will be while men remain
men, but a service is to be judged by its general spirit, and by the
view it takes of errors and failures. Nobody who looks critically at the
history of the British Navy in the eighteenth century can fail to note
a vast difference between the years before and those after 1757.
And we insult the memory of the seamen of the eighteenth century
if we suppose that this is so only because the wrath of the nation
drove them to greater exertion, or that they did not think the
execution of Byng just. Some did not. His second in command,
Temple West, resigned rather than continue to serve if he was to be
liable to punishment for “an error of judgment.” West by the use of
that phrase gave currency to a sophism which has often been used
to obscure the real significance of this great sacrifice. But the navy
had not protested against the change in the Naval Discipline Act of
1749. The officers who tried Byng did not shrink from applying the
law though it cut them to the heart to send a brother in arms to a
shameful death. If they had been dishonest men, they might have
acquitted him of negligence, but they saw the truth and they did
their terrible duty. There is nothing to show that the seamen,
whether on the quarter-deck or before the mast, did, as a body,
think the sentence unjust. Indeed, the whole navy was now burning
with a spirit which asked for nothing better than to be relieved of
such leadership as Byng’s.
Three months after the admiral met his fate, the great
administration of the elder Pitt was formed. At last the power of
England was about to be directed, not by pettifogging and
parliamentary intrigue, but by genius and passion. Yet the full effect
of the change could not be felt for a space, and until 1758 was well
advanced the work of Newcastle may be said to overlap that of Pitt.
We may look for a moment at the interval before the power of the
navy was fully free to act.
When Hawke superseded Byng in July 1756 it was too late to save
Minorca, and no means were at hand for its recovery. He cruised
unopposed by the French till December, and then returned home,
leaving the command to Admiral Saunders. The interest on both
sides was centred now in North America. The French had to
reinforce and support their colonies. Our aim was to intercept their
succours, and to make ourselves masters of the French port at the
mouth of the St. Lawrence, as preparatory to the conquest of
Canada. At home our Channel fleet was to watch Brest, and our
Mediterranean fleet to keep a check on Toulon; while in America
preparations were making to attack Cape Breton upon the arrival of
a naval force from England. The work of watching the French ports
was not uniformly well done. In April a squadron of four sail under
the command of M. Durevest escaped Saunders in the Straits of
Gibraltar after a slight brush, and held on to America. In May, Vice-
Admiral Henry Osborn came out with reinforcements, and took over
the command. The total force was thirteen of the line and two 50-
gun ships, a much larger force than the French ships at Toulon could
hope to face in open battle. Osborn was a good representative of
that large body of naval officers whose names are associated with
no single action of great renown, but who did much and varied
service, and who contributed to the glory of more fortunate rivals by
weary cruising and vigilant watch far away from the scene where
more brilliant reputations were being earned. He was also a very
typical officer of his time, when the life of the chief was one of stern
solitude, and his exercise of authority was harsh. By nature Osborn
was of a cold, saturnine disposition. He made no friends, and if he
did not actively make enemies his hand weighed on all under his
command with oppressive severity. But his vigilance, his strenuous
discharge of duty, and his severe exaction of their utmost from his
subordinates fitted him admirably for the work he had to do in the
Mediterranean, in 1757 and the early months of 1758.
The loss of Minorca imposed a heavy disadvantage on the British
admiral who had to watch Toulon. The nearest port at which vessels
could be docked was Gibraltar, and this was a serious consideration
before the use of copper sheathing had been introduced, and when
ships grew rapidly foul. In December, when Osborn was at the Rock,
M. de la Clue left Toulon with five sail of the line and one 50-gun
ship, in the hope that he might elude his opponent and follow
Durevest to America. But Osborn was on the watch in the Straits,
and La Clue put into the Spanish port of Carthagena. Here he was
watched rather than blockaded. Two more liners and a frigate
succeeded in slipping in and joining him. On the 5th February 1758
he put out to meet reinforcements promised him from Toulon, and
went as far as Palos; but his friends did not appear, and fearing to
have the whole British squadron on his hands, he returned to
Carthagena. On the 25th February a reinforcement did appear off
the port. It consisted of the Foudroyant, 80, commanded by Captain
Duquesne, who had with him the Orphée, 64, and the Oriflamme,
50. Duquesne declined to come within the island of Escombrera,
which lies at the mouth of Carthagena harbour, and waited outside
to be joined by La Clue. A squall drove him to sea, where his little
squadron was sighted, scattered, and chased by Osborn. The
Orphée struck to the Revenge and the Berwick. The Oriflamme was
driven on shore, but succeeded in getting off and joining La Clue in
Carthagena. A noble story is connected with the fortunes of the
Foudroyant.
Among the ships under Admiral Osborn’s command was the
Monmouth, 64, a poor little liner of our starved model, but a quick
sailer. She was commanded by Arthur Gardiner, who had been flag-
captain to Byng in the miserable battle of Minorca, and his first
lieutenant was Robert Carkett, one of those officers who rose from
before the mast. Little is known of Gardiner, save that he had been
chosen by Byng to be his flag-captain, which implies that he was a
“follower” of his admiral and was under obligations to him. In the
battle he had given Byng good and manly advice, and in the court
martial his evidence had told severely against his chief. The memory
of that day had rankled in Gardiner’s mind. Now La Galissonière’s
flag had flown in the Foudroyant in the battle, and the English
captain had come to regard her with a concentrated hatred. He is
reported to have said that whenever he met her he would attack her,
at all odds, and either take her or perish. Charnock, to whom the
traditions of the navy of that time came directly, quotes a letter
telling how “Two days before he left his port (viz. Gibraltar) being in
company with Lord Robert Bertie, and other persons, he with great
anguish of soul told them, that my Lord Anson had reflected on him,
and said he was one of the men who had brought disgrace upon the
nation; that it touched him excessively, but it ran strongly in his
mind, that he should have an opportunity shortly to convince his
lordship how much he had the honour of the nation at heart, and
that he was not culpable.”
When now, on the morning of the 28th February 1758, Gardiner
found himself among the chasing ships of Osborn’s squadron, and
saw the French ships in flight, he singled out the mighty Foudroyant,
and crowded sail in pursuit. The Swiftsure and the Hampton Court
accompanied him, but they were heavy sailers and soon fell behind.
The chase began early in the morning, and was prolonged till
evening, when the Foudroyant and the Monmouth were alone. As he
pressed on the chase, Captain Gardiner, so tradition recorded by
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

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

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like