100% found this document useful (2 votes)
20 views

eTextbook 978-0134285436 Java Foundations: Introduction to Program Design and Data Structures (4th Edition) instant download

The document provides an overview of the eTextbook 'Java Foundations: Introduction to Program Design and Data Structures (4th Edition)', detailing its structure and content aimed at introductory programming courses. It highlights new features in the fourth edition, including a chapter on JavaFX and enhancements to existing topics. Additionally, it outlines the chapter breakdown, covering fundamental programming concepts, data structures, and algorithm analysis.

Uploaded by

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

eTextbook 978-0134285436 Java Foundations: Introduction to Program Design and Data Structures (4th Edition) instant download

The document provides an overview of the eTextbook 'Java Foundations: Introduction to Program Design and Data Structures (4th Edition)', detailing its structure and content aimed at introductory programming courses. It highlights new features in the fourth edition, including a chapter on JavaFX and enhancements to existing topics. Additionally, it outlines the chapter breakdown, covering fundamental programming concepts, data structures, and algorithm analysis.

Uploaded by

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

eTextbook 978-0134285436 Java Foundations:

Introduction to Program Design and Data


Structures (4th Edition) pdf download

https://ebookmass.com/product/etextbook-978-0134285436-java-
foundations-introduction-to-program-design-and-data-
structures-4th-edition/

Explore and download more ebooks at ebookmass.com


We have selected some products that you may be interested in
Click the link to download now or visit ebookmass.com
for more options!.

C++ Programming. Program Design including Data Structures


8th Edition D.S. Malik

https://ebookmass.com/product/c-programming-program-design-including-
data-structures-8th-edition-d-s-malik/

eTextbook 978-1285856872 C# Programming: From Problem


Analysis to Program Design

https://ebookmass.com/product/etextbook-978-1285856872-c-programming-
from-problem-analysis-to-program-design/

eTextbook 978-0134448237 C++ How to Program (10th Edition)

https://ebookmass.com/product/etextbook-978-0134448237-c-how-to-
program-10th-edition/

Starting Out with Java: From Control Structures through


Data Structures 3rd Edition, (Ebook PDF)

https://ebookmass.com/product/starting-out-with-java-from-control-
structures-through-data-structures-3rd-edition-ebook-pdf/
Data structures and algorithm analysis in Java 3rd ed
Edition Mark Allen Weiss

https://ebookmass.com/product/data-structures-and-algorithm-analysis-
in-java-3rd-ed-edition-mark-allen-weiss/

eTextbook 978-1305575073 Introduction to Health Care

https://ebookmass.com/product/etextbook-978-1305575073-introduction-
to-health-care/

eTextbook 978-1305969766 Introduction to Criminal Justice

https://ebookmass.com/product/etextbook-978-1305969766-introduction-
to-criminal-justice/

eTextbook 978-1305251472 Introduction to Process


Technology

https://ebookmass.com/product/etextbook-978-1305251472-introduction-
to-process-technology/

eTextbook 978-0135121030 Police Administration:


Structures, Processes, and Behavior

https://ebookmass.com/product/etextbook-978-0135121030-police-
administration-structures-processes-and-behavior/
Preface

Welcome to Java Foundations. This book is designed to serve as the primary resource for a two- or three-term
introductory course sequence, ranging from the most basic programming concepts to the design and implementation
of complex data structures. This unified approach makes the important introductory sequence more cohesive and
accessible for students.

We’ve borrowed the best elements from the industry-leading text Java Software Solutions for the introductory material,
reworked to complement the design and vision of the overall text. For example, instead of having graphics sections
spread throughout many chapters, the coverage of graphical user interfaces is accomplished in a well-organized
chapter of its own.

In the later chapters, the exploration of collections and data structures is modeled after the coverage in Java Software
Structures, but has been reworked to flow cleanly from the introductory material. The result is a comprehensive,
cohesive, and seamless exploration of programming concepts.

New in the Fourth Edition

We appreciate the feedback we’ve received about this book and are pleased that it continues to serve so well as an
introductory text. The following modifications have been made to improve the presentation of particular topics and
the overall flow:

 Added a new chapter on JavaFX (Chapter 26).

 Added an application in Chapter 18 that animates the sort algorithms to compare efficiency.

 Added an introduction to thread processing as part of the new sort animation example.

 Added a new section on the use of the Comparator interface.

 Revised the discussion of binary search trees to provide a more comprehensive introduction.

Your feedback indicated that you did not want to see the discussion of Swing completely replaced by JavaFX coverage,
so we’ve kept the Swing content and added a new JavaFX chapter. Eventually, JavaFX will replace Swing, but with the
huge amount of code relying on it, knowledge of Swing will be important for quite a while.

In the third edition, we had established the following flow when discussing collections:

The feedback has indicated that this modification was well received and we have continued and reinforced its use. It
clarifies the distinction between the way the Java API supports a particular collection and the way it might be
implemented from scratch. It makes it easier for instructors to point out limitations of the API implementations in a
compare-and-contrast fashion. This approach also allows an instructor, on a case-by-case basis, to simply introduce a
collection without exploring implementation details if desired.

We think these modifications build upon the strong pedagogy established by previous editions and give instructors
more opportunity and flexibility to cover topics as they choose.
Chapter Breakdown

 Chapter 1 (Introduction) introduces the Java programming language and the basics of program
development. It contains an introduction to object-oriented development, including an overview of
concepts and terminology. This chapter contains broad introductory material that can be covered while
students become familiar with their development environment.

 Chapter 2 (Data and Expressions) explores some of the basic types of data used in a Java program and the
use of expressions to perform calculations. It discusses the conversion of data from one type to another,
and how to read input interactively from the user with the help of the Scanner class.

 Chapter 3 (Using Classes and Objects) explores the use of predefined classes and the objects that can be
created from them. Classes and objects are used to manipulate character strings, produce random numbers,
perform complex calculations, and format output. Packages, enumerated types, and wrapper classes are
also discussed.

 Chapter 4 (Conditionals and Loops) covers the use of boolean expressions to make decisions. All related
statements for conditionals and loops are discussed, including the enhanced version of the for loop. The
Scanner class is revisited for iterative input parsing and reading text files.

 Chapter 5 (Writing Classes) explores the basic issues related to writing classes and methods. Topics include
instance data, visibility, scope, method parameters, and return types. Constructors, method design, static
data, and method overloading are covered as well. Testing and debugging are now covered in this chapter
as well.

 Chapter 6 (Graphical User Interfaces) is a thorough exploration of Java GUI processing, focusing on
components, events, and listeners. Many types of components and events are discussed using numerous
GUI examples. Additionally, layout managers, containment hierarchies, borders, tooltips, and mnemonics
are introduced.

 Chapter 7 (Arrays) contains extensive coverage of arrays and array processing. Topics include bounds
checking, initializer lists, command-line arguments, variable-length parameter lists, and multidimensional
arrays.

 Chapter 8 (Inheritance) covers class derivations and associated concepts such as class hierarchies,
overriding, and visibility. Strong emphasis is put on the proper use of inheritance and its role in software
design.

 Chapter 9 (Polymorphism) explores the concept of binding and how it relates to polymorphism. Then we
examine how polymorphic references can be accomplished using either inheritance or interfaces. Design
issues related to polymorphism are examined as well.

 Chapter 10 (Exceptions) covers exception handling and the effects of uncaught exceptions. The try-catch
statement is examined, as well as a discussion of exception propagation. The chapter also explores the use
of exceptions when dealing with input and output, and examines an example that writes a text file.

 Chapter 11 (Analysis of Algorithms) lays the foundation for determining the efficiency of an algorithm and
explains the important criteria that allow a developer to compare one algorithm to another in proper ways.
Our emphasis in this chapter is understanding the important concepts more than getting mired in heavy
math or formality.

 Chapter 12 (Introduction to Collections—Stacks) establishes the concept of a collection, stressing the need
to separate the interface from the implementation. It also conceptually introduces a stack, then explores an
array-based implementation of a stack.

 Chapter 13 (Linked Structures - Stacks) discusses the use of references to create linked data structures. It
explores the basic issues regarding the management of linked lists, and then defines an alternative
implementation of a stack (introduced in Chapter 3) using an underlying linked data structure.
 Chapter 14 (Queues) explores the concept and implementation of a first-in, first-out queue. Radix sort is
discussed as an example of using queues effectively. The implementation options covered include an
underlying linked list as well as both fixed and circular arrays.

 Chapter 15 (Lists) covers three types of lists: ordered, unordered, and indexed. These three types of lists
are compared and contrasted, with discussion of the operations that they share and those that are unique
to each type. Inheritance is used appropriately in the design of the various types of lists, which are
implemented using both array-based and linked representations.

 Chapter 16 (Iterators) is a new chapter that isolates the concepts and implementation of iterators, which
are so important to collections. The expanded discussion drives home the need to separate the iterator
functionality from the details of any particular collection.

 Chapter 17 (Recursion) is a general introduction to the concept of recursion and how recursive solutions
can be elegant. It explores the implementation details of recursion and discusses the basic idea of analyzing
recursive algorithms.

 Chapter 18 (Searching and Sorting) discusses the linear and binary search algorithms, as well as the
algorithms for several sorts: selection sort, insertion sort, bubble sort, quick sort, and merge sort.
Programming issues related to searching and sorting, such as using the Comparable interface as the basis of
comparing objects, are stressed in this chapter. An application uses animation to demonstrate the efficiency
of sorting algorithms. The comparator interface is examined and demonstrated as well.

 Chapter 19 (Trees) provides an overview of trees, establishing key terminology and concepts. It discusses
various implementation approaches and uses a binary tree to represent and evaluate an arithmetic
expression.

 Chapter 20 (Binary Search Trees) builds off of the basic concepts established in Chapter 10 to define a
classic binary search tree. A linked implementation of a binary search tree is examined, followed by a
discussion of how the balance in the tree nodes is key to its performance. That leads to exploring AVL and
red/black implementations of binary search trees.

 Chapter 21 (Heaps and Priority Queues) explores the concept, use, and implementations of heaps and
specifically their relationship to priority queues. A heap sort is used as an example of its usefulness as well.
Both linked and array-based implementations are explored.

 Chapter 22 (Sets and Maps) explores these two types of collections and their importance to the Java
Collections API.

 Chapter 23 (Multi-way Search Trees) is a natural extension of the discussion of the previous chapters. The
concepts of 2-3 trees, 2-4 trees, and general B-trees are examined and implementation options are
discussed.

 Chapter 24 (Graphs) explores the concept of undirected and directed graphs and establishes important
terminology. It examines several common graph algorithms and discusses implementation options,
including adjacency matrices.

 Chapter 21 (Databases) explores the concept of databases and their management, and discusses the basics
of SQL queries. It then explores the techniques for establishing a connection between a Java program and a
database, and the API used to interact with it.

 Chapter 21 (JavaFX) presents several examples using the new JavaFX framework for GUIs and graphics. A
comparison of the Swing and JavaFX approaches is followed by an introduction to several JavaFX elements.
The JavaFX Scene Builder application is explored as well.

Supplements

The following student resources are available for this book:

 Source code for all programs presented in the book


 VideoNotes that explore select topics from the book

Resources can be accessed at www.pearsonhighered.com/lewis/

The following instructor resources can be found at Pearson Education’s Instructor Resource Center:

 Solutions for select exercises and programming projects in the book

 Powerpoint slides for the presentation of the book content

 Test bank

To obtain access, please visit www.pearsonhighered.com/irc or contact your local Pearson Education sales
representative.
Contents

1. Preface vii

2. Credits xxx

3. VideoNotes xxxii

4. Chapter 1. Introduction 1

1. 1.1 The Java Programming Language 2

1. A Java Program 3

2. Comments 5

3. Identifiers and Reserved Words 7

4. White Space 9

2. 1.2 Program Development 11

1. Programming Language Levels 11

2. Editors, Compilers, and Interpreters 13

3. Development Environments 15

4. Syntax and Semantics 16

5. Errors 17

3. 1.3 Problem Solving 18

4. 1.4 Software Development Activities 20

5. 1.5 Object-Oriented Programming 21

1. Object-Oriented Software Principles 22

5. Chapter 2 Data and Expressions 33

1. 2.1 Character Strings 34

1. The print and println Methods 34

2. String Concatenation 36

3. Escape Sequences 40

2. 2.2 Variables and Assignment 41

1. Variables 41

2. The Assignment Statement 44

3. Constants 46

3. 2.3 Primitive Data Types 47

1. Integers and Floating Points 47

2. Characters 48
3. Booleans 50

4. 2.4 Expressions 51

1. Arithmetic Operators 51

2. Operator Precedence 52

3. Increment and Decrement Operators 56

4. Assignment Operators 57

5. 2.5 Data Conversion 58

1. Conversion Techniques 60

6. 2.6 Reading Input Data 61

1. The Scanner Class 61

6. Chapter 3 Using Classes and Objects 75

1. 3.1 Creating Objects 76

1. Aliases 78

2. 3.2 The String Class 80

3. 3.3 Packages 83

1. The import Declaration 84

4. 3.4 The Random Class 86

5. 3.5 The Math Class 89

6. 3.6 Formatting Output 92

1. The NumberFormat Class 92

2. The DecimalFormat Class 94

3. The printf Method 96

7. 3.7 Enumerated Types 97

8. 3.8 Wrapper Classes 100

1. Autoboxing 102

7. Chapter 4 Conditionals and Loops 111

1. 4.1 Boolean Expressions 112

1. Equality and Relational Operators 113

2. Logical Operators 114

2. 4.2 The if Statement 116

1. The if-else Statement 119

2. Using Block Statements 121

3. The Conditional Operator 124

4. Nested if Statements 125


3. 4.3 Comparing Data 127

1. Comparing Floats 127

2. Comparing Characters 127

3. Comparing Objects 128

4. 4.4 The switch Statement 130

5. 4.5 The while Statement 134

1. Infinite Loops 140

2. Nested Loops 141

3. Other Loop Controls 144

6. 4.6 Iterators 145

1. Reading Text Files 146

7. 4.7 The do Statement 148

8. 4.8 The for Statement 151

1. Iterators and for Loops 156

2. Comparing Loops 157

8. Chapter 5 Writing Classes 169

1. 5.1 Classes and Objects Revisited 170

1. Identifying Classes and Objects 171

2. Assigning Responsibilities 173

2. 5.2 Anatomy of a Class 173

1. Instance Data 178

2. UML Class Diagrams 179

3. 5.3 Encapsulation 181

1. Visibility Modifiers 182

2. Accessors and Mutators 183

4. 5.4 Anatomy of a Method 188

1. The return Statement 194

2. Parameters 196

3. Local Data 197

4. Constructors Revisited 198

5. 5.5 Static Class Members 199

1. Static Variables 199

2. Static Methods 200

6. 5.6 Class Relationships 203


1. Dependency 203

2. Dependencies among Objects of the Same Class 204

3. Aggregation 206

4. The this Reference 211

7. 5.7 Method Design 212

1. Method Decomposition 213

2. Method Parameters Revisited 218

8. 5.8 Method Overloading 223

9. 5.9 Testing 224

1. Reviews 225

2. Defect Testing 226

3. Unit Testing 227

4. Integration Testing 228

5. System Testing 228

6. Test-Driven Development 228

10. 5.10 Debugging 229

1. Simple Debugging with print Statements 230

2. Debugging Concepts 230

9. Chapter 6 Graphical User Interfaces 245

1. 6.1 GUI Elements 246

1. Frames and Panels 247

2. Buttons and Action Events 251

3. Determining Event Sources 253

2. 6.2 More Components 256

1. Text Fields 257

2. Check Boxes 260

3. Radio Buttons 263

4. Sliders 267

5. Combo Boxes 272

6. Timers 277

3. 6.3 Layout Managers 282

1. Flow Layout 285

2. Border Layout 288

3. Grid Layout 291


Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
4. Box Layout 293

5. Containment Hierarchies 296

4. 6.4 Mouse and Key Events 297

1. Mouse Events 297

2. Key Events 305

3. Extending Adapter Classes 310

5. 6.5 Dialog Boxes 311

1. File Choosers 314

2. Color Choosers 316

6. 6.6 Some Important Details 317

1. Borders 317

2. Tool Tips and Mnemonics 321

7. 6.7 GUI Design 328

10. Chapter 7 Arrays 339

1. 7.1 Array Elements 340

2. 7.2 Declaring and Using Arrays 341

1. Bounds Checking 344

2. Alternative Array Syntax 349

3. Initializer Lists 350

4. Arrays as Parameters 351

3. 7.3 Arrays of Objects 351

4. 7.4 Command-Line Arguments 361

5. 7.5 Variable-Length Parameter Lists 363

6. 7.6 Two-Dimensional Arrays 367

1. Multidimensional Arrays 370

11. Chapter 8 Inheritance 379

1. 8.1 Creating Subclasses 380

1. The protected Modifier 385

2. The super Reference 386

3. Multiple Inheritance 390

2. 8.2 Overriding Methods 391

1. Shadowing Variables 394

3. 8.3 Class Hierarchies 394

1. The Object Class 395


2. Abstract Classes 397

4. 8.4 Visibility 399

5. 8.5 Designing for Inheritance 401

1. Restricting Inheritance 402

12. Chapter 9 Chapter 9 Polymorphism 411

1. 9.1 Dynamic Binding 412

2. 9.2 Polymorphism via Inheritance 413

3. 9.3 Interfaces 425

1. Interface Hierarchies 430

2. The Comparable Interface 431

3. The Iterator Interface 431

4. 9.4 Polymorphism via Interfaces 432

1. Event Processing 434

13. Chapter 10 Exceptions 441

1. 10.1 Exception Handling 442

2. 10.2 Uncaught Exceptions 443

3. 10.3 The try-catch Statement 444

1. The finally Clause 447

4. 10.4 Exception Propagation 448

5. 10.5 The Exception Class Hierarchy 451

1. Checked and Unchecked Exceptions 455

6. 10.6 I/O Exceptions 455

14. Chapter 11 Analysis of Algorithms 465

1. 11.1 Algorithm Efficiency 466

2. 11.2 Growth Functions and Big-Oh Notation 467

3. 11.3 Comparing Growth Functions 469

4. 11.4 Determining Time Complexity 471

1. Analyzing Loop Execution 471

2. Nested Loops 472

3. Method Calls 473

15. Chapter 12 Introduction to Collections—Stacks 479

1. 12.1 Collections 480

1. Abstract Data Types 481

2. The Java Collections API 483


2. 12.2 A Stack Collection 483

3. 12.3 Crucial OO Concepts 485

1. Inheritance and Polymorphism 486

2. Generics 487

4. 12.4 Using Stacks: Evaluating Postfix Expressions 488

1. Javadoc 496

5. 12.5 Exceptions 497

6. 12.6 A Stack ADT 498

7. 12.7 Implementing a Stack: With Arrays 501

1. Managing Capacity 502

8. 12.8 The ArrayStack Class 503

1. The Constructors 504

2. The push Operation 506

3. The pop Operation 508

4. The peek Operation 509

5. Other Operations 509

6. The EmptyCollectionException Class 510

7. Other Implementations 511

16. Chapter 13 Linked Structures—Stacks 519

1. 13.1 References as Links 520

2. 13.2 Managing Linked Lists 522

1. Accessing Elements 522

2. Inserting Nodes 523

3. Deleting Nodes 524

3. 13.3 Elements without Links 525

1. Doubly Linked Lists 525

4. 13.4 Stacks in the Java API 526

5. 13.5 Using Stacks: Traversing a Maze 527

6. 13.6 Implementing a Stack: With Links 536

1. The LinkedStack Class 536

2. The push Operation 540

3. The pop Operation 542

4. Other Operations 543

17. Chapter 14 Chapter 14 Queues 549


1. 14.1 A Conceptual Queue 550

2. 14.2 Queues in the Java API 551

3. 14.3 Using Queues: Code Keys 552

4. 14.4 Using Queues: Ticket Counter Simulation 556

5. 14.5 A Queue ADT 561

6. 14.6 A Linked Implementation of a Queue 562

1. The enqueue Operation 564

2. The dequeue Operation 566

3. Other Operations 567

7. 14.7 Implementing Queues: With Arrays 568

1. The enqueue Operation 572

2. The dequeue Operation 574

3. Other Operations 575

8. 14.8 Double-Ended Queues (Dequeue) 575

18. Chapter 15 Lists 581

1. 15.1 A List Collection 582

2. 15.2 Lists in the Java Collections API 584

3. 15.3 Using Unordered Lists: Program of Study 585

4. 15.4 Using Indexed Lists: Josephus 595

5. 15.5 A List ADT 597

1. Adding Elements to a List 598

6. 15.6 Implementing Lists with Arrays 603

1. The remove Operation 605

2. The contains Operation 607

3. The add Operation for an Ordered List 608

4. Operations Particular to Unordered Lists 609

5. The addAfter Operation for an Unordered List 609

7. 15.7 Implementing Lists with Links 610

1. The remove Operation 611

19. Chapter 16 Iterators 619

1. 16.1 What’s an Iterator? 620

1. Other Iterator Issues 622

2. 16.2 Using Iterators: Program of Study Revisited 622

1. Printing Certain Courses 626


2. Removing Courses 627

3. 16.3 Implementing Iterators: With Arrays 629

4. 16.4 Implementing Iterators: With Links 631

20. Chapter 17 Recursion 637

1. 17.1 Recursive Thinking 638

1. Infinite Recursion 638

2. Recursion in Math 639

2. 17.2 Recursive Programming 640

1. Recursion versus Iteration 643

2. Direct versus Indirect Recursion 643

3. 17.3 Using Recursion 644

1. Traversing a Maze 644

2. The Towers of Hanoi 652

4. 17.4 Analyzing Recursive Algorithms 657

21. Chapter 18 Searching and Sorting 665

1. 18.1 Searching 666

1. Static Methods 667

2. Generic Methods 667

3. Linear Search 668

4. Binary Search 670

5. Comparing Search Algorithms 672

2. 18.2 Sorting 673

1. Selection Sort 676

2. Insertion Sort 678

3. Bubble Sort 680

4. Quick Sort 682

5. Merge Sort 686

3. 18.3 Radix Sort 689

4. 18.3 Sorting Efficiency and Introduction to Threads 693

1. Threads 694

2. The Sort Comparison Demo 694

5. 18.3 A Different Way to Sort—Comparator 707

22. Chapter 19 Trees 719

1. 19.1 Trees 720


1. Tree Classifications 721

2. 19.2 Strategies for Implementing Trees 723

1. Computational Strategy for Array Implementation of Trees 723

2. Simulated Link Strategy for Array Implementation of Trees 723

3. Analysis of Trees 725

3. 19.3 Tree Traversals 726

1. Preorder Traversal 726

2. Inorder Traversal 727

3. Postorder Traversal 727

4. Level-Order Traversal 728

4. 19.4 A Binary Tree ADT 729

5. 19.5 Using Binary Trees: Expression Trees 733

6. 19.6 A Backpain Analyzer 745

7. 19.7 Implementing Binary Trees with Links 750

1. The find Method 754

2. The iteratorInOrder Method 756

23. Chapter 20 Binary Search Trees 763

1. 20.1 Binary Search Trees 764

1. Adding an Element to a Binary Search Tree 765

2. Removing an Element from a Binary Search Tree 766

2. 20.2 Implementing a Binary Search Tree 769

20.2 Implementing Binary Search Trees: With Links 771

1. The addElement Operation 772

2. The removeElement Operation 774

3. The removeAllOccurrences Operation 778

4. The removeMin Operation 779

5. Implementing Binary Search Trees: With Arrays 781

3. 20.3 Using Binary Search Trees: Implementing Ordered Lists 781

1. Analysis of the BinarySearchTreeList Implementation 784

4. 20.4 Balanced Binary Search Trees 785

1. Right Rotation 786

2. Left Rotation 787

3. Rightleft Rotation 788

4. Leftright Rotation 788


5. 20.5 Implementing Binary Search Trees: AVL Trees 788

1. Right Rotation in an AVL Tree 789

2. Left Rotation in an AVL Tree 790

3. Rightleft Rotation in an AVL Tree 790

4. Leftright Rotation in an AVL Tree 791

6. 20.6 Implementing Binary Search Trees: Red/Black Trees 792

1. Insertion into a Red/Black Tree 792

2. Element Removal from a Red/Black Tree 796

24. Chapter 21 Heaps and Priority Queues 805

1. 21.1 A Heap 806

1. The addElement Operation 808

2. The removeMin Operation 809

3. The findMin Operation 810

2. 21.2 Using Heaps: Priority Queues 810

3. Implementing Heaps: With Links 814

1. The addElement Operation 814

2. The removeMin Operation 818

3. The findMin Operation 821

4. 21.4 Implementing Heaps: With Arrays 821

1. The addElement Operation 823

2. The removeMin Operation 824

3. The findMin Operation 826

5. 21.5 Using Heaps: Heap Sort 826

25. Chapter 22 Sets and Maps 833

1. 22.1 Set and Map Collections 834

2. 22.2 Sets and Maps in the Java API 834

3. 22.3 Using Sets: Domain Blocker 837

4. 22.4 Using Maps: Product Sales 840

5. 22.5 Using Maps: User Management 844

6. 22.6 Implementing Sets and Maps Using Trees 849

7. 22.7 Implementing Sets and Maps Using Hashing 849

26. Chapter 23 Multi-way Search Trees 857

1. 23.1 Combining Tree Concepts 858

2. 23.2 2-3 Trees 858


1. Inserting Elements into a 2-3 Tree 859

2. Removing Elements from a 2-3 Tree 861

3. 23.3 2-4 Trees 864

4. 23.4 B-Trees 866

1. B*-Trees 867

2. B+-Trees 867

3. Analysis of B-Trees 868

5. 23.5 Implementation Strategies for B-Trees 868

27. Chapter 24 Graphs 875

1. 24.1 Undirected Graphs 876

2. 24.2 Directed Graphs 877

3. 24.3 Networks 879

4. 24.4 Common Graph Algorithms 880

1. Traversals 880

2. Testing for Connectivity 884

3. Minimum Spanning Trees 886

4. Determining the Shortest Path 889

5. 24.5 Strategies for Implementing Graphs 889

1. Adjacency Lists 890

2. Adjacency Matrices 890

6. 24.6 Implementing Undirected Graphs with an Adjacency Matrix 891

1. The addEdge Method 896

2. The addVertex Method 896

3. The expandCapacity Method 897

4. Other Methods 898

28. Chapter 25 Databases 905

1. 25.1 Introduction to Databases 906

2. 25.2 Establishing a Connection to a Database 908

1. Obtaining a Database Driver 908

3. 25.3 Creating and Altering Database Tables 911

1. Create Table 911

2. Alter Table 912

3. Drop Column 913

4. 25.4 Querying the Database 913


1. Show Columns 914

5. 25.5 Inserting, Viewing, and Updating Data 916

1. Insert 917

2. SELECT . . . FROM 917

3. Update 922

6. 25.6 Deleting Data and Database Tables 923

1. Deleting Data 923

2. Deleting Database Tables 924

29. Appendix A Glossary 947

30. Appendix B Number Systems 981

1. Place Value 982

2. Bases Higher Than 10 983

3. Conversions 984

4. Shortcut Conversions 987

31. Appendix C The Unicode Character Set 993

32. Appendix D Java Operators 997

1. Java Bitwise Operators 999

33. Appendix E Java Modifiers 1003

1. Java Visibility Modifiers 1004

2. A Visibility Example 1004

3. Other Java Modifiers 1005

34. Appendix F Java Graphics 1007

1. Coordinate Systems 1008

2. Representing Color 1008

3. Drawing Shapes 1009

4. Polygons and Polylines 1018

5. The Polygon Class 1022

35. Appendix G Java Applets 1027

1. Embedding Applets in HTML 1030

1. More Applet Methods 1030

2. GUIs in Applets 1035

36. Appendix H Regular Expressions 1045

37. Appendix I Hashing 1047

1. I.1 A Hashing 1048


2. I.2 Hashing Functions 1049

1. The Division Method 1050

2. The Folding Method 1050

3. The Mid-Square Method 1051

4. The Radix Transformation Method 1051

5. The Digit Analysis Method 1051

6. The Length-Dependent Method 1052

7. Hashing Functions in the Java Language 1052

3. I.3 Resolving Collisions 1052

1. Chaining 1053

2. Open Addressing 1054

4. I.4 Deleting Elements from a Hash Table 1057

1. Deleting from a Chained Implementation 1057

2. Deleting from an Open Addressing Implementation 1058

5. I.5 Hash Tables in the Java Collections API 1059

1. The Hashtable Class 1059

2. The HashSet Class 1061

3. The HashMap Class 1061

4. The IdentityHashMap Class 1062

6. The WeakHashMap Class 1063

1. LinkedHashSet and LinkedHashMap 1064

38. Appendix J Java Syntax 1071

39. Appendix G Index 1085


Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
Exploring the Variety of Random
Documents with Different Content
former ambassador to Rome. M. Jules de Lasteyrie, the only son,
was made a senator. He married a lady of the English branch of the
House of Rohan-Chabot. His only son holds an office at present at
Abbeville. The third and youngest daughter of the Marquis de
Lasteyrie married M. d’Assailly, and is mother of two sons: one,
councillor-general of the Deux-Sèvres; the other, a captain of
Chasseurs.
“The connections of the La Fayette family are distinguished and
numerous. Through the De Grammonts, they are allied to the Count
de Merode, senator from the Department of the Doubs; to his
brother, who held high office under Pius IX.; and to Anna, Countess
of Montalembert. The family of Ségur is also related to the La
Fayette family.”
Beranger called La Fayette “L’Homme des deux mondes” (the man
of two worlds), and he might also have added, the man of two
centuries. Europe and America have both united to do him homage,
and the glorious independence which he aided in securing in one
century, he lived to behold in the next, realizing greater permanency
and prosperity than even his fondest dreams had dared to hope for.
The American Republic held him in grateful remembrance as a
Revolutionary Hero; while France venerated his memory as the
Friend and Protector of the People. High on the lists of chivalry the
name of La Fayette glows with undying lustre; but as the defender
of the oppressed and the protector of the weak, he is the People’s
Hero.
While his remains were being carried to the tomb, surrounded by
an escort of the National Guard, a poor man, with tattered clothing
and tottering steps, endeavored to press his way through the crowd
and place himself in the funeral procession directly behind the bier.
One of the Guard, obstructing his passage, said to him, “You see
that none but the family are admitted here.”
“We all belong to his family,” replied the old man, with a voice
choked with emotion and eyes full of tears; “we all belong to his
family, for he loved us all as his children.”
Immediately the ranks of the National Guard fell reverently
backward, and a way was quickly opened for the old peasant, and
he walked to the cemetery directly behind the remains of him whose
self-sacrificing devotion had won for him this beautiful testimony of
love and honor; and in the name of humanity and brotherly
kindness, this old man—unconsciously—laid upon the tomb of La
Fayette the most precious memorial which could be offered to his
memory.
In the Château of Chavaniac, in the province of Auvergne, the
Marquis de La Fayette was born and passed the first seven or eight
years of his life. He was so frail a child that for some years the
indications were strong that he would enjoy only a brief career.
Being fatherless, his education was the care of his mother, who
faithfully performed her sacred duties.
A faint tinge of health began gradually to glow in his cheeks, his
attenuated frame showed some signs of vigor, and the presage of an
early death became less foreboding. While his body had been so
frail, however, his mind had made rapid progress.
To a friend he said in after years: “You ask me at what period I
first experienced my ardent love for liberty and glory. I recollect no
time of life anterior to my enthusiasm for anecdotes of glorious
deeds, and to my projects of travelling over the world to acquire
fame. At eight years of age my heart beat when I heard of a wolf
that had done some injury, and caused still more alarm in our
neighborhood, and the hope of meeting it was the object of all my
walks. When I arrived at college, nothing ever interrupted my
studies except my ardent wish to study without restraint. I never
deserved to be chastised, but, in spite of my usual gentleness, it
would have been dangerous to attempt to do so. I recollect with
pleasure that, when I was to describe in rhetoric a perfect courser, I
sacrificed the hope of obtaining a prize, and described the one
which, on perceiving the whip, threw his rider.
“Republican anecdotes always delighted me, and when my new
connections wished to obtain for me a place at court, I did not
hesitate displeasing them to preserve my independence.”
CHÂTEAU OF CHAVANIAC.—LAFAYETTE’S BIRTHPLACE.

At the age of twelve years La Fayette was entered at the college


of Louis le Grand, in Paris, where he zealously pursued his studies.
In Latin and Greek classics he became especially proficient. Owing to
his high rank his literary pursuits were subject to frequent
interruptions, for he early gained the attention of royalty, and the
gay French court was very alluring to a youth passionately fond of
brilliant society. However, his love for study and his enthusiasm for
the military calling prevented his becoming a courtier. By the death
of his mother in 1770, and of his grandfather a short time after, he
became possessed of great wealth, which, being entirely at his own
control, surrounded him with a crowd of fawning flatterers. At the
age of fifteen he became a page to Queen Marie Antoinette, and
was enrolled a member of the Mousquetaires du Roi, the body-guard
of the king, which was composed solely of the descendants of the
most highly titled families in France. Through the influence of the
queen, he was promoted to the rank of a commissioned officer in
this corps. Speaking of which, he said “that his military services only
interrupted his studies on review days.”
At the age of sixteen La Fayette was married to the Comtesse de
Noailles, daughter of the Duke d’Ayen. Madame de La Fayette herself
gives the following account of her somewhat strange wooing.
“I was scarcely twelve years old, when M. de La Fayette was
proposed to my mother for one of us. He himself was only fourteen.
His extreme youth, no parents to guide him,—having lost all his near
relatives, and having no one in whom he could repose confidence,—
a large fortune already in his possession, which my mother looked
upon as a dangerous gift—all these considerations made her at first
refuse him, notwithstanding the good opinion she had acquired of
his personal qualities. She persisted several months in her refusal;
but my father was not discouraged, and as one of his friends
observed to him that my mother had gone too far ever to change
her mind, he did justice to her straightforwardness in the midst of
his anger against her. ‘You do not know Madame d’Ayen,’ he said;
‘however far she may have gone, you will see that she will give way
like a child if you prove to her that she is in the wrong; but, on the
other hand, she will never yield if she does not see her mistake.’
“Accordingly, when she was told that her daughter would not leave
her during the first years of her marriage, and that it would only be
celebrated at the end of two years, after M. de La Fayette had
finished his education, she accepted him whom she cherished ever
after as the most tenderly beloved son, whom she valued from the
first moment that she became acquainted with him, and who alone
could have sustained the strength of my heart after having lost her.
“It was some time after my mother’s consent that I was spoken to
of M. de La Fayette, towards whom I was already attracted by feeble
forerunners of that deep and tender affection which every day has
united us more and more in the midst of all the vicissitudes of this
life, in the midst of the blessings and misfortunes which have filled it
for the last twenty-four years.
“With what pleasures I learned that, for more than a year, my
mother had looked upon him and loved him as a son! She told me all
the good she had heard with regard to him, all she thought of him
herself, and I saw that he already felt for her that filial affection
which was to be the blessing of my life. She tried to calm my poor
weak brain, which was over-excited by the importance of the coming
event. She taught me to pray—she prayed herself—for the blessings
of Heaven on my future happiness. As I had the happiness of
remaining with her, my only feelings were those of deep emotion. I
was then fourteen and a half.”
La Fayette’s wife brought to him a fortune, which, together with
his own inheritance, gave him a yearly revenue of $37,500.
The young marquis is thus described at this time: “He was then a
handsome young man, of commanding figure and pleasing features,
notwithstanding his deep red hair. His forehead, though receding,
was fine; his eyes clear hazel, and his mouth and chin delicately
formed, exhibiting beauty rather than strength. The expression of his
countenance was strongly indicative of a generous and gallant spirit,
with an air of conscious greatness.
“His manners were frank and amiable, his movements light and
graceful. Formed, both by nature and education, to be the ornament
of a court, and already distinguished by his varied and attractive
qualities in the circle of his noble acquaintance, his free principles
were neither withered by the sunshine of royalty, nor weakened by
flattery and temptation. He dressed in a costume then worn by a
gentleman who affected not the extreme of fashion, nor the reverse.
His bearing was elegant, full of vivacity, and his conversational
powers were of a high order, and their activity varied much with his
moods, sometimes mild and winning, and again ardent and
enthusiastic.”
In the summer of 1776 La Fayette, as an officer of the French
army, was stationed on military duty in the citadel of Metz. At this
time he was little over eighteen years of age. Through the Duke of
Gloucester, a brother of the king of England, La Fayette first learned
of the struggles in America. The Duke of Gloucester had been exiled
from the court of Great Britain on account of his impolitic marriage,
and was then at Metz. The duke was constantly receiving reports of
the American struggle for independence, and he openly described
the plans of the British ministry to crush this uprising of the
colonists. La Fayette’s fiery ardor in the cause of liberty was
quickened at the news of the oppressed Americans, fighting with
such vast odds against them, bravely defying the most powerful
nation on the globe.
La Fayette immediately resigned his position at Metz, and
hastened to Paris, determined to devote his life and fortune to the
aid of the courageous band of patriots who had just declared their
independence.
Knowing the opposition he would meet from family, friends, and
the government, he made his preparations with the greatest secrecy,
not even revealing his intentions to his wife, to whom he was most
devoted. His heaven-born principles of liberty could no longer be
kept in check by inaction, and he was ready to sacrifice every
personal interest in life to the cause of oppressed humanity.
After having partially completed his arrangements, La Fayette
disclosed his scheme to his relative the Count de Broglie. The count
was bitterly opposed to the undertaking, and pictured to La Fayette
all the difficulties and dangers of the enterprise. “Your uncle
perished in the wars in Italy,” said he; “your father fell in the battle
of Minden; and now I will not be accessory to the ruin of the only
remaining branch of the family.”
But nothing could quench the ardor of the dauntless La Fayette.
He found in the Baron de Kalb a kindred sympathy, and through the
baron, the Marquis de La Fayette was introduced to Mr. Silas Deane,
who had been sent by the American Congress to negotiate with the
French government. La Fayette made known to Mr. Deane his
generous desire to offer his personal services in the American war.
Whereupon Mr. Deane gave to him the following paper:—
“The desire which the Marquis de La Fayette shows of serving
among the troops of the United States of North America, and the
interest which he takes in the justice of their cause, makes him wish
to distinguish himself in this war, and to render himself as useful as
he possibly can. But not thinking that he can obtain leave of his
family to pass the seas and to serve in a foreign country till he can
go as a general officer, I have thought that I could not better serve
my country and those who have entrusted me, than by granting to
him, in the name of the very honorable Congress, the rank of major-
general, which I beg the states to confirm and ratify to him, and to
deliver him the commission to hold and take rank from this day with
the general officers of the same degree.
“His high birth, his alliances, the great dignities which his family
hold at this court, his considerable estates in this realm, his personal
merit, his reputation, his disinterestedness, and above all, his zeal
for the liberty of our provinces, are such as to induce me alone to
promise him the rank of major-general in the name of the United
States. In witness of which I have signed these presents this 7th day
of December, 1776.
“Silas Deane.”

“The secrecy,” says La Fayette, “with which this negotiation and


my preparations were made, appears almost a miracle; family,
friends, ministers, French spies, and English spies, all were kept
completely in the dark as to my intentions.”
But just at this time news of disastrous defeats in the
Revolutionary army reached France. The bells of London rang out
joyful peals at this welcome intelligence; but many sympathizing
hearts in Paris saddened at this dire misfortune to the little band
fighting for their rightful independence. The court of Versailles had
not yet openly espoused the American cause, and now Louis XVI.
and others, friendly to the Americans, waited for more encouraging
prospects before lending their aid. But not so the liberty-loving La
Fayette. He was never so great as when in the midst of the most
stupendous difficulties, and he was never so true and faithful and
staunch in his patriotic principles, as when the cause to which he
was attached hung trembling betwixt victory and defeat.
Discouragements but nerved him to new ardor; obstacles but
strengthened his determination to overcome every barrier in the way
of his successful progress. His was truly a soul and nature most
eminently fitted for the important part he was called upon to take in
the struggle for liberty and freedom.
At this time affairs in the new world were in a most desperate
condition. The battle of Brooklyn had been fought, resulting in the
total rout of the continental forces, and the evacuation of Long
Island. New York, after an heroic resistance, had been given up to
the British. General Howe was master of Forts Washington and Lee.
General Washington, with the remnants of the army, with tattered
uniforms and scanty food, was retreating before the foe. The
country was in despair. Dark indeed were the clouds which threw
their shadows over sorrowful homes and the suffering patriots of the
struggling nation.
LOUIS XVI.

Even the American commissioners at Paris were paralyzed by this


dreadful blow. They dared not urge the French further in the behalf
of their stricken country, which seemed doomed to defeat. They
even counselled La Fayette to abandon his project of enlisting in
their cause, representing to him that their affairs were now so
desperate that they could not offer him a passage to America, nor
any assurance of success should he venture to go. But La Fayette’s
love of liberty was not dependent upon success or defeat. His
principles were as unflinching in disaster as when crowned with
victory; and to La Fayette’s courage America in a large measure
owes her ultimate success. Study the history of those times, and
then try to answer the question, What would have been the result of
the American Revolution, without the aid of La Fayette?
To the discouraged commissioners, La Fayette made this noble
reply:—
“I thank you for your frankness, but now is precisely the moment
to serve your cause; the more people are discouraged, the greater
utility will result from my departure. Until now you have only seen
my ardor in your cause, but that may not prove at present wholly
useless. If you cannot furnish me with a vessel, I will purchase one
and freight it at my own expense, to convey your despatches and
my person to the shores of America.”
With unflagging labor La Fayette now occupied himself in carrying
out his promised plan. From his own estates he raised the money
necessary for the expedition, and prepared to purchase and equip a
vessel. King Louis, owing to the recent reverses in America, began to
distrust the expediency of an open alliance. La Fayette, being
suspected of favoring the American cause, was constantly watched
by French and English spies. To escape the knowledge of his family
and the royal surveillance, the ship was purchased through La
Fayette’s friend, Mr. Duboismartin, who warmly sympathized with his
liberal principles. In the midst of these preparations La Fayette was
sent by the French government on a diplomatic mission to London.
Lest he should excite suspicion by refusal, La Fayette departed for
England with his associate, the Prince de Poix. On reaching London,
it was a significant fact that before La Fayette paid his respects to
the British court, he sought an interview with Bancroft, the
American.
La Fayette was received at the English court with every mark of
distinguished honor, but court flatteries were little now to his taste.
He was yearning to return to Paris, to continue his preparations for
his chivalrous project.
“At the end of three weeks,” he writes, “when it became necessary
for me to return home, while refusing to accompany my uncle, the
ambassador, to court, I confided to him my strong desire to take a
trip to Paris. He suggested that he should say that I was ill during
my absence. I should not have made use of this stratagem myself,
but did not object to his doing so.”
Hastening back to Paris, he continued his secret preparations.
Without making known his return to any of his friends, with the
exception of those interested in his plans, La Fayette set out for
Bordeaux, where a ship was being equipped for him. But information
regarding his mysterious manœuvres was now communicated to the
court of Versailles, and led to an order for his arrest. La Fayette,
being warned, departed to Passage, a Spanish port, intending to
embark for America from there. He now openly avowed his
intentions, and declared that nothing should induce him to relinquish
his plans.
MARIE ANTOINETTE.

But now his firmness was put to the severest test. Letters arrived
from his family, containing the bitterest reproaches. He was even
accused of want of parental care and gross neglect of his wife and
home. This was indeed hard to bear. La Fayette was deeply in love
with his winsome and affectionate wife. But with an unselfishness
which amounted to the sublimity of heroism, his young wife
restrained her tears, lest he should be blamed, and bravely
determined to bear the parting uncomplainingly. Such a heroine as
she afterwards proved herself to be made her a truly worthy
companion for her hero-husband.
Letters came, also, under kingly authority, forbidding his
embarkation for America, threatening severe displeasure in case of
disobedience. Sovereign displeasure, La Fayette was well aware,
meant liability to the confiscation of all his property, and public
disgrace. Feigning obedience, La Fayette returned to Bordeaux, and
wrote to the ministry, requesting permission to carry out his plans,
representing the benefits which France would derive by the wresting
of this coveted land from proud England. But the king was not
prepared to excite the wrath of his powerful neighbor, and no reply
was sent directly to La Fayette, though he was made to understand,
through friends, that his petition had been refused.
He shortly afterwards received orders to proceed to Marseilles,
and join himself to the Duke d’Ayen, who was going into Italy. La
Fayette now determined to brave all hazards. He accordingly
departed ostensibly for Marseilles, but soon changed his route and
went directly to Passage, and there embarked on his gallant ship
Victory, and unfurled the sails, pointing the prow of his vessel
towards the land of liberty. As soon as it was ascertained that La
Fayette had gone, despatches were sent to arrest him at the West
Indies. But La Fayette, suspecting this, ordered his captain to steer
directly for America.
His wearisome voyage lasted for two months. Seasickness added
its discomforts to the anxieties, regrets, and aspiring longings which
made keen warfare in his saddened heart. Would his wife forgive
him for this seeming desertion? Would his country renounce him?
Would his unselfish and magnanimous sacrifice avail in the cause of
liberty, which was the ruling passion of his life? Weak with sickness
and tempest-tossed, he addressed to his wife these pathetic letters:

“On board the Victory, May 30, 1777.


“... How many fears and anxieties enhance the keen anguish I feel
at being separated from all that I love most fondly in the world! How
have you borne my second departure? Have you loved me less?
Have you pardoned me? Have you reflected that, at all events, I
must equally have been parted from you—wandering about in Italy,
dragging on an inglorious life, surrounded by the persons most
opposed to my projects and to my manner of thinking? All these
reflections did not prevent me from experiencing the most bitter
grief when the moment arrived for quitting my native shores. Your
sorrow, and that of my friends, all rushed upon my thoughts; and
my heart was torn by a thousand painful feelings. I could not, at
that instant, find any excuse for my own conduct. If you could know
all that I have suffered, and the melancholy days that I have passed
while thus flying from all that I love best in the world! Must I join to
this affliction the grief of hearing that you do not pardon me? I
should, in truth, my love, be too unhappy.”

Again he writes:—

“On board the Victory, June 7.


“I am still floating upon this dreary plain, the most wearisome of
all human habitations. To console myself a little I think of you and of
my friends. I think of the pleasure of seeing you again. How
delightful will be the moment of my arrival! I shall hasten to surprise
and embrace you. I shall, perhaps, find you with your children. To
think, only, of that happy moment is an inexpressible pleasure to me
—do not fancy that it is distant; although the time of my absence
will appear, I confess, very long to me, yet we shall meet sooner
than you can expect. While defending the liberty which I adore, I
shall enjoy perfect freedom myself; I but offer my services to that
interesting Republic from motives of the purest kind, unmixed with
ambition or private views; her happiness and my glory are my only
incentives to the task. I hope, that for my sake, you will become a
good American, for that feeling is worthy of every noble heart. The
happiness of America is intimately connected with the happiness of
all mankind. She will become the safe and respected asylum of
virtue, integrity, toleration, equality, and tranquil happiness.”
CHAPTER II.

Arrival in America—Letter to his Wife from Charleston—La Fayette’s


First Impressions of America—Letter from Petersburg—Arrival in
Philadelphia—Chilling Reception by Congress—La Fayette’s
Magnanimous Offer—Resolution passed by Congress—The First
Meeting between Liberty’s Knight and the “Man of the Age”—
Washington’s Kindly Reception of the Young Marquis—Letter from
Franklin to Washington regarding La Fayette—Battle of Brandywine
—La Fayette wounded—Letter to his Wife from Philadelphia—La
Fayette in the Care of the Moravian Society—Letter to his Wife—La
Fayette’s Home Life described by his Daughter Virginie—La Fayette
again in the Field—The Battle of Gloucester—Congress
commissions the Marquis to the Command of a Division—Winter
Quarters at Valley Forge—Letter from La Fayette to his Father-in-
law, the Duke d’Ayen—His Impressions regarding American Affairs
—A Treacherous Intrigue against Washington—La Fayette’s Manly
Letter to him—Washington’s Noble Reply—The New Board of War—
La Fayette appointed to the Command of the Expedition into
Canada—His Letter to Washington from Albany—Expedition to
Canada abandoned—La Fayette’s Return to Valley Forge—Sir
William Howe outwitted by the Young Marquis—La Fayette’s
Influence in the Army—Death of La Fayette’s Little Daughter—His
Touching Letter to his Wife.

“When Freedom from her mountain height


Unfurled her standard to the air,
She tore the azure robe of night
And set the stars of glory there.”—Drake.
ON the 14th of June, 1777, La Fayette landed at Winyau Bay,
about sixty miles northeast from Charleston. Nature had clothed
herself in her loveliest garb to welcome the knight of liberty who had
sacrificed wealth and luxury and the gay life of courts, to unsheathe
his sword in this new land in defence of freedom.
It was midnight under the soft June skies. The stars glowed in
benediction, and the moon shed a calm radiance over the scene. As
the canoe conveyed the travellers up the picturesque bay, the
wooded land beyond seemed to stretch out its leafy hands of
welcome, and the air was perfumed with the delicious fragrance of
innumerable flowers. Such was America’s greeting to her brave
defender.
Of this, let La Fayette’s own letters speak. Back to the love of his
heart, the wife whose constant devotion was his guiding star, fly
quickly his thoughts, on the swift wings of affection, and he hastens
to pen these lines:—

“June 19.
“I landed at Charleston, after having sailed for several days along
a coast swarming with hostile vessels. On my arrival here every one
told me that my ship would undoubtedly be taken, because two
English frigates had blockaded the harbor. I even sent, both by land
and by sea, orders to the captain to put the men on shore, and burn
the vessels, if he had still the power of doing so. Eh bien! by a most
extraordinary piece of good fortune, a sudden gale of wind having
blown away the frigates for a short time, my vessel arrived at
noonday, without having encountered friend or foe. At Charleston I
have met General Howe, a general officer now engaged in service.
The governor of the state is expected this evening from the country.
All the persons with whom I wished to be acquainted have shown
me the greatest attention and politeness—not European politeness
merely. I can only feel gratitude for the reception tendered me,
although I have not yet thought proper to enter into any details
respecting my future prospects and arrangements. I wish to see the
Congress first. I hope to set out in two days for Philadelphia, which
is a land journey of more than two hundred and fifty leagues. We
shall divide into small parties. I have already purchased horses and
light carriages for this purpose.
“I shall now speak to you, my love, about the country and its
inhabitants, who are as agreeable as my enthusiasm led me to
imagine. Simplicity of manner, kindness of heart, love of country and
of liberty, and a delightful state of equality are universal. The richest
and the poorest men are completely on a level; and, although there
are some immense fortunes in this country, I may challenge any one
to point out the slightest difference in their respective manner
toward each other. I first saw and judged of a country life at Major
Huger’s house. I am at present in this city, where I notice a
resemblance to English customs, except that I find more simplicity
here than in England.
“Charleston is one of the best built, handsomest, and most
agreeable cities that I have ever seen. The American women are
very pretty, and have great simplicity of character. The extreme
neatness of their appearance is truly delightful. Cleanliness is
everywhere even more studiously regarded here than in England.
What gave me most pleasure is to see how completely the citizens
are all brethren of one family. In America there appear to be none
poor, and none even who can be called peasants. Each citizen has
some property, and all citizens have the same rights as the richest
individual or landed proprietor in the country. The inns are very
different from those in Europe; the host and hostess sit at table with
you, and do the honors of a comfortable meal, and when you depart
you pay your bill without being obliged to fee attendants. If you
dislike going to inns, you always find country houses, in which you
will be received as a good American, with the same attention that
you expect to find at a friend’s house in Europe.
“My own reception has been peculiarly agreeable. To have been
merely my travelling companion suffices to secure the kindest
welcome. I have just passed five hours at a large dinner, given in
compliment to me by an individual of this town. Generals Howe and
Moultrie, and several officers of my suite, were present. We drank
each other’s health, and endeavored to talk English, which I am
beginning to speak a little. I shall pay a visit to-morrow, with these
gentlemen, to the governor of the state, and make the last
arrangements for my departure. The next day the commanding
officer here will take me to see the town and its environs, and I shall
then set out to join the army.
“From the agreeable life I lead in this country, from the sympathy
which makes me feel as much at ease with the inhabitants as if I
had known them twenty years, the similarity between their manner
of thinking and my own, my love of glory and liberty, you might
imagine that I am very happy; but you are not with me, my dearest
love; my friends are not with me; and there is no happiness for me
when far away from you and them. I often ask you if you still love,
but I put that question still more often to myself, and my heart ever
answers yes. I trust that my heart does not deceive me. I am
inexpressibly anxious to hear from you, and hope to find some
letters at Philadelphia. My only fear is lest the privateer which was to
bring them to me may have been captured on her way. Although I
can easily imagine that I have excited the special displeasure of the
English, by taking the liberty of coming hither in spite of them and
landing before their very face, yet I must confess that we shall be
even more than on a par if they succeed in catching that vessel, the
object of my fondest hopes, by which I am expecting to receive your
letters.
“I entreat you to send me both long and frequent letters. You are
not sufficiently conscious of the joy with which I shall receive them.
Embrace, most tenderly, my Henriette; may I add, embrace our
children! The father of those poor children is a wanderer, but he is,
nevertheless, a good, honest man, a good father, warmly attached to
his family, and a good husband also, for he loves his wife most
tenderly. The night is far advanced, the heat intense, and I am
devoured by mosquitoes; but the best countries, as you perceive,
have their inconveniences. Adieu, my love, adieu.”

Again La Fayette writes to his wife from Petersburg, Va., July 17,
1777:—
“I am now eight days’ journey from Philadelphia, in the beautiful
state of Virginia. All fatigue is over, and I fear that my martial labors
will be very light if it be true that General Howe has left New York, to
go I know not whither. But all the accounts I receive are so
uncertain that I cannot form any fixed opinion until I reach my
destination.
“You must have learned the particulars of the beginning of my
journey. You know that I set out in a brilliant manner, in a carriage,
and I must now tell you that we are all on horseback,—having
broken the carriage according to my usual praiseworthy custom,—
and I expect soon to write to you that we have arrived on foot. The
journey is somewhat fatiguing; but, although several of my
comrades have suffered a great deal, I have scarcely, myself, been
conscious of fatigue. The captain, who takes charge of this letter, will
perhaps pay you a visit. I beg you, in that case, to receive him with
great kindness.
“The farther I advance to the north, the better pleased I am with
the country and its inhabitants. There is no attention or kindness
that I do not receive, although many scarcely know who I am. But I
will write all this to you more in detail from Philadelphia.”
As soon as La Fayette arrived in Philadelphia, he presented himself
before Congress, then in session. The moment was inauspicious. Mr.
Deane had given so many foreigners the same promises, that
Congress found itself in a very embarrassing situation. Many of these
foreigners were brave men, and true, who had come to America with
philanthropic motives, but others were mere adventurers, and
Congress therefore received the young Marquis de La Fayette with
coldness and indifference, which he illy deserved, and which in the
light of after events proved a mortifying mistake. La Fayette laid his
stipulations with Mr. Deane before Congress, but, with surprise and
chagrin, he was informed by the chairman of the Committee on
Foreign Affairs that there was little hope that his request would be
granted.
Imagine the feelings of the noble young marquis of nineteen. He
had sacrificed home, family, friends, and fortune, to give his aid to
this struggling nation, and his immense personal sacrifices were thus
insultingly thrown into his face. What blindness in Congress! What
heroic magnanimity in La Fayette! Pride and patriotism battled in his
sensitive soul. But unselfish patriotism conquered, and never does
he appear more truly great than at this moment. Seizing a pen, he
writes to Congress this brief but immortal note:—
“After the sacrifices I have made, I have a right to exact two
favors: one is, to serve at my own expense; the other is, to serve as
a volunteer.”
Astonished at such unprecedented generosity, and conscious of
their mistake in classing the young marquis with other foreigners,
who were actuated by selfish avarice and love of adventure,
Congress accordingly passed the following preamble and resolution
on the 31st of July, 1777:—

“Whereas, the Marquis de La Fayette, out of his great zeal in the


cause of liberty in which the United States are engaged, has left his
family and connections, and, at his own expense, come over to offer
his service to the United States, without pension or particular
allowance, and is anxious to risk his life in our cause;
“Resolved, That his services be accepted, and that in consideration
of his zeal, illustrious family and connections, he have the rank and
commission of a Major-General in the army of the United States.”

La Fayette’s first meeting with Washington was at a dinner party in


Philadelphia, on the 1st of August. The commander-in-chief looked
with sympathy upon the noble young hero, and their hearts were
quickly united in a bond of friendship which ignored diversity of age,
country, and experience, for they mutually recognized a self-
sacrificing devotion to the sacred and sublime cause of human
liberty.
“When the company were about to separate, Washington took La
Fayette aside, spoke to him very kindly, complimented him on the
noble spirit he had shown, and the sacrifices he had made in favor
of the American cause, and then told him that he should be pleased
if he would make the headquarters of the commander-in-chief his
home, establish himself there whenever he thought proper, and
consider himself at all times as one of his family; adding in a tone of
pleasantry, that he could not promise him the luxuries of a court, or
even the conveniences which his former habits might have rendered
essential to comfort; but since he had become an American soldier
he would doubtless contrive to accommodate himself to the
character he had assumed, and submit with a good grace to the
customs, manners, and privations of the republican army.”
Little was the bold spirit of La Fayette dismayed at the prospect of
difficulties and privations. His soul could not be confined by
hardships, dangers, or even defeats. He eagerly accepted the
invitation of Washington, and well repaid his kindly courtesy. It was
about this time that the following letter was written from Paris by
Franklin to Washington:—

“Sir: The Marquis de La Fayette, a young nobleman of great


expectations and exceedingly beloved here, is by this time probably
with you. By some misapprehension in his contract with the
merchants of Bordeaux he was prevented from using the produce of
the cargo he carried over, and so was left without a supply of
money. His friends here have sent him over about £500 sterling, and
have proposed sending him more; but on reflection, knowing the
extreme generosity of his disposition, and fearing that some of his
necessitous and artful countrymen may impose on his goodness,
they wish to put his money into the hands of some discreet friend,
who may supply him from time to time, and by that means knowing
his expenses, may take occasion to advise him if necessary, from too
much imposition.
“They accordingly have desired us to name such a person to
them. We have not been able to think of one so capable and so
suitable from the influence of situation to perform that kind office as
General Washington, under whose eye the gentleman will probably
be.
“We beg, therefore, in his behalf, what his friends out of respect
would not take the liberty of asking, that Your Excellency would be
pleased to furnish him with what money he may want in moderation,
and take his drafts payable to us for sums paid him, which we shall
receive here, and apply to the public service.
“We also join with his family in their earnest request that you
would favor him with your counsels, which you may be assured will
be an act of benevolence gratefully remembered and acknowledged
by a number of very worthy persons here who have interested
themselves extremely in the welfare of that amiable young
nobleman.
“With the greatest respect we have the honor to be, Sir, Your
Excellency’s.”

The commission which La Fayette had received from Congress


was, as yet, only an honorary one, conferring upon him no real
command. La Fayette was now with Washington at his headquarters.
He was yearning for active duties, and impatient to prove by
personal exploits his zeal in the cause of liberty. Washington wrote
to Congress regarding La Fayette’s position, but received the
unsatisfactory reply, “that the commission given to the Marquis de La
Fayette was only honorary, and that he could not yet receive an
appointment.” Again did the generous spirit of the young hero meet
only a cold rebuff in answer to his warm offers of personal service.
He determined now to win his position by his own actions, and the
opportunity was not long in arriving.
On the 11th of September, 1777, was fought the battle of
Brandywine. “The British fleet under Sir William Howe, whose
movements along the American coast at one time seeming to
threaten Philadelphia, and at another appearing to meditate an
attack upon Charleston, had caused much apprehension and doubt,
had, at last, entered the Chesapeake; and, having proceeded up the
Elk River as far as it was safely navigable, landed the forces at the
ferry on the 25th of August. The determination of an assault upon
Philadelphia was no longer questionable. The day before Sir William
Howe landed, General Washington, to inspire the citizens with
confidence, paraded his troops through the streets of Philadelphia,
and then proceeded boldly to the Brandywine. The popular clamor,
favored by the voice of Congress, demanded a battle, and
Washington determined to risk one, though he greatly apprehended
that he could not successfully compete with the strength of the
battalions marching against him. But a battle, though disastrous,
would be less injurious than to suffer the enemy to advance to
Philadelphia without opposition.
“Washington, having halted for a few days on the banks of the
Brandywine to refresh his troops, and get a better knowledge of the
face of the country and the plans of the enemy, sent forward two
divisions under Green and Stephens, who proceeded nearer to the
head of the Elk, and encamped behind White Clay Creek. Three
miles farther on, at Iron Hill, was stationed General Maxwell, at the
head of an effective corps of light infantry, formed from a regiment
of Morgan’s riflemen, which had been detached to the northern
army.
“Posting the cavalry along the lines, Washington, with the main
body, crossed the Brandywine, and took up his position behind Red
Clay Creek, on the road which Sir William Howe would have to
traverse on his march to Philadelphia. La Fayette was with him, and
watched with the liveliest interest the preparations for the
approaching contest. These were made with consummate adroitness
and prudence; but Sir William Howe was no common foe; and the
direction which he seemed contemplating for his vastly superior
force decided Washington that a change of his own position was
necessary. A council of war was held on the night of the 9th of
September, when it was determined to retire behind the Brandywine,
and meet the enemy near Chadd’s Ford, from the heights which
ranged along upon the opposite side of the river.
“On the morning of the 11th of September, soon after daybreak,
La Fayette sprang to his feet at the intelligence that the whole British
army was in motion, and advancing towards them on the direct road
leading over Chadd’s Ford. General Maxwell had been
advantageously stationed, so that he could command this road from
the hills, on the south side of the river; and the first action
accordingly began with him.
“The foe advanced in two magnificent columns, the right
commanded by General Knyphausen, and the left by Lord Cornwallis.
The plan of Howe was, that Knyphausen’s division should occupy the
attention of the Americans, by making repeated feints of attempting
the passage of the ford, while Cornwallis should make a long sweep
up the river, and cross it at Birmingham. Knyphausen accordingly
advanced with his column, and speedily dislodging General Maxwell
from his post, forced him to cross over, though with but little loss. A
furious cannonading was instantly begun, and other demonstrations
made, which indicated the intention of the British immediately to
attempt the passage of the ford. The day was occupied in preventing
this, till eleven o’clock in the morning, when the movement of
Cornwallis was first announced to Washington. A smile of delight
played upon his countenance, and he immediately determined upon
one of those bold but judicious plans for which he was remarkable.
“Placing himself at the head of the centre and left wing of the
army, he resolved to cross the river in person, and overwhelm
Knyphausen before Cornwallis could be summoned back to his aid.
His ranks were already formed for the passage, and his troops had
answered to the proposition with deafening shouts, when a
messenger arrived with the intelligence that Cornwallis had only
made a feint of crossing the fords above, and was now actually
bringing his division down the southern side of the river, to re-unite
with Knyphausen. The tidings were agony to Washington; though,
false, they came in a form which constrained him to believe them
true, and his bold project was accordingly abandoned. His troops
were impatient for the encounter, but for two hours he could only
give them quiet directions, while he endeavored, in distressing
suspense, to gain some clew to the movements of the enemy on the
opposite side.
“At about two o’clock in the afternoon his uncertainty was
removed, when certain intelligence reached him, that Lord
Cornwallis, after having made a circuit of nearly seventeen miles,
had forded the river above its forks, and, accompanied by Sir William
Howe, was advancing upon him. Close action was immediately
prepared for, and all along the American lines ran the accents of
welcome for the conflict. The three divisions which formed the right
wing, under Generals Sullivan, Stirling, and Stephens, were
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookmasss.com

You might also like