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

(eBook PDF) Big Java: Early Objects, 6th Edition by Cay S. Horstmann 2024 scribd download

The document promotes the eBook 'Big Java: Early Objects, 6th Edition' by Cay S. Horstmann, available for download on ebookluna.com, along with several other Java-related eBooks. It highlights the advantages of the eBook format, including lower prices and additional interactive features. The content covers various programming concepts, object-oriented design, data structures, and includes online resources for enhanced learning.

Uploaded by

fratusdugme
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)
13 views

(eBook PDF) Big Java: Early Objects, 6th Edition by Cay S. Horstmann 2024 scribd download

The document promotes the eBook 'Big Java: Early Objects, 6th Edition' by Cay S. Horstmann, available for download on ebookluna.com, along with several other Java-related eBooks. It highlights the advantages of the eBook format, including lower prices and additional interactive features. The content covers various programming concepts, object-oriented design, data structures, and includes online resources for enhanced learning.

Uploaded by

fratusdugme
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/ 43

Get the full ebook with Bonus Features for a Better Reading Experience on ebookluna.

com

(eBook PDF) Big Java: Early Objects, 6th Edition


by Cay S. Horstmann

https://ebookluna.com/product/ebook-pdf-big-java-early-
objects-6th-edition-by-cay-s-horstmann/

OR CLICK HERE

DOWLOAD NOW

Download more ebook instantly today at https://ebookluna.com


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

(eBook PDF) Big Java: Early Objects 5th Edition

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

ebookluna.com

(eBook PDF) Big Java: Early Objects, 7th Edition

https://ebookluna.com/product/ebook-pdf-big-java-early-objects-7th-
edition/

ebookluna.com

(eBook PDF) Python for Everyone, 2nd Edition by Cay S.


Horstmann

https://ebookluna.com/product/ebook-pdf-python-for-everyone-2nd-
edition-by-cay-s-horstmann/

ebookluna.com

(eBook PDF) Big Java Late Objects 2nd Edition

https://ebookluna.com/product/ebook-pdf-big-java-late-objects-2nd-
edition/

ebookluna.com
(eBook PDF) Starting Out with Java Early Objects 6th
Edition by Tony Gaddis

https://ebookluna.com/product/ebook-pdf-starting-out-with-java-early-
objects-6th-edition-by-tony-gaddis/

ebookluna.com

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

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

ebookluna.com

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


Edition

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

ebookluna.com

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


Global Edition

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

ebookluna.com

(eBook PDF) Java How to Program, Early Objects 11th


Edition by Paul J. Deitel

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

ebookluna.com
Cay Horstmann

Big Java
6/e Early Objects

Includes Java 8 coverage

Horstmann_BJ6_JC8_cvs_final_cj.indd 1 4/29/15 1:46 PM


vi Preface

Part B: Object-Oriented Design (Chapters 8–12)


Chapter 8 takes up the subject of class design in a systematic fashion, and it intro-
duces a very simple subset of the UML notation. The discussion of polymorphism
and inheritance is split into two chapters. Chapter 9 covers inheritance and polymor-
phism, whereas Chapter 10 covers interfaces. Exception handling and basic file input/
output are covered in Chapter 11. The exception hierarchy gives a useful example for

1. Introduction

Fundamentals
2. Using Objects
Object-Oriented Design
Data Structures & Algorithms
Applied Topics
3. Implementing
Online Chapters
Classes

4. Fundamental
Data Types

5. Decisions

6. Loops

Sections 11.1 and 11.2


(text file processing) can be 7. Arrays
covered with Chapter 6. 6. Iteration
and Array Lists

11. Input/Output 8. Designing


13. Recursion
and Exception Classes
Handling

21. Advanced 23. Internet 24. Relational 15. The Java 14. Sorting
9. Inheritance
Input/Output Networking Databases Collections and Searching
Framework

26. Web
Applications 19. Stream
Processing

20. Graphical 22. 16. Basic


25. XML 10. Interfaces
User Interfaces Multithreading Data Structures

Figure 1 12. Object-


Chapter Oriented Design 18. Generic 17. Tree
Classes Structures
Dependencies
Preface vii

inheritance. Chapter 12 contains an introduction to object-oriented design, including


two significant case studies.

Part C: Data Structures and Algorithms (Chapters 13–19)


Chapters 13 through 19 contain an introduction to algorithms and data structures,
covering recursion, sorting and searching, linked lists, binary trees, and hash tables.
These topics may be outside the scope of a one-semester course, but can be covered
as desired after Chapter 7 (see Figure 1). Recursion, in Chapter 13, starts with simple
examples and progresses to meaningful applications that would be difficult to imple-
ment iteratively. Chapter 14 covers quadratic sorting algorithms as well as merge sort,
with an informal introduction to big-Oh notation. Each data structure is presented
in the context of the standard Java collections library. You will learn the essential
abstractions of the standard library (such as iterators, sets, and maps) as well as the
performance characteristics of the various collections. Chapter 18 introduces Java
generics. This chapter is suitable for advanced students who want to implement their
own generic classes and methods. Finally, Chapter 19 introduces the Java 8 streams
library and shows how it can be used to analyze complex real-world data.

Part D: Applied Topics (Chapters 20–26)


Chapters 20 through 26 cover Java programming techniques that definitely go
beyond a first course in Java (21–26 are on the book’s companion site). Although, as
already mentioned, a comprehensive coverage of the Java library would span many
© Alex Slobodkin/iStockphoto.

volumes, many instructors prefer that a textbook should give students additional
reference material valuable beyond their first course. Some institutions also teach a
second-semester course that covers more practical programming aspects such as data-
base and network programming, rather than the more traditional in-depth material
on data structures and algorithms. This book can be used in a two-semester course
to give students an introduction to programming fundamentals and broad coverage
of applications. Alternatively, the material in the final chapters can be useful for stu-
dent projects. The applied topics include graphical user-interface design, advanced
file handling, multithreading, and those technologies that are of particular interest to
server-side programming: networking, databases, XML, and web applications. The
Internet has made it possible to deploy many useful applications on servers, often
accessed by nothing more than a browser. This server-centric approach to application
development was in part made possible by the Java language and libraries, and today,
much of the industrial use of Java is in server-side programming.

Appendices
Many instructors find it highly beneficial to require a consistent style for all assign-
ments. If the style guide in Appendix E conflicts with instructor sentiment or local
customs, however, it is available in electronic form so that it can be modified. Appen-
dices F–J are available on the Web.
A. The Basic Latin and Latin-1 F. Tool Summary
Subsets of Unicode G. Number Systems
B. Java Operator Summary H. UML Summary
C. Java Reserved Word Summary I. Java Syntax Summary
D. The Java Library J. HTML Summary
E. Java Language Coding Guidelines
viii Preface

Custom Book and eBook Options


Big Java may be ordered in both custom print and eBook formats. You can order a
custom print version that includes your choice of chapters—including those from
other Horstmann titles. Visit customselect.wiley.com to create your custom order.
Big Java is also available in an electronic eBook format with three key advantages:
• The price is significantly lower than for the printed book.
• The eBook contains all material in the printed book plus the web chapters and
worked examples in one easy-to-browse format.
• You can customize the eBook to include your choice of chapters.
The interactive edition of Big Java adds even more value by integrating a wealth of
interactive exercises into the eBook. See http://wiley.com/go/bjeo6interactivities to
find out more about this new format.
Please contact your Wiley sales rep for more information about any of these
options or check www.wiley.com/college/horstmann for available versions.

Web Resources
This book is complemented by a complete suite of online resources. Go to www.wiley.
com/college/horstmann to visit the online companion sites, which include

• Source code for all example programs in the book and its Worked Examples, plus
additional example programs.
• Worked Examples that apply the problem-solving steps in the book to other
realistic examples.
• Lecture presentation slides (for instructors only).
• Solutions to all review and programming exercises (for instructors only).
• A test bank that focuses on skills, not just terminology (for instructors only). This
extensive set of multiple-choice questions can be used with a word processor or
imported into a course management system.
• “CodeCheck” assignments that allow students to work on programming prob-
lems presented in an innovative online service and receive immediate feedback.
Instructors can assign exercises that have already been prepared, or easily add
their own.

WORKED EXAMPLE 6.3 A Sample Debugging Session


Learn how to find bugs in an algorithm for counting the
Pointers in the book syllables of a word. Go to wiley.com/go/bjeo6examples and
download Worked Example 6.3.
describe what students
will find on the Web.
FULL CODE EXAMPLE

Go to wiley.com/go/
bjeo6code to download
a program that dem-
onstrates variables
and assignments.
Walkthrough ix

Walkthrough of the Learning Aids


The pedagogical elements in this book work together to focus on and reinforce key
concepts and fundamental principles of programming, with additional tips and detail
organized to support and deepen these fundamentals. In addition to traditional
features, such as chapter objectives and a wealth of exercises, each chapter contains
elements geared to today’s visual learner.

250 Chapter 6 Loops

6.3 The for Loop


Throughout each chapter,
It often happens that you want to execute a sequence of statements a given number
margin notes show where The for loop is
used when a of times. You can use a while loop that is controlled by a counter, as in the following
example:
new concepts are introduced
value runs from a
starting point to an
ending point with a int counter = 1; // Initialize the counter
and provide an outline of key ideas. constant increment
or decrement.
while (counter <= 10) // Check the counter
{
System.out.println(counter);
counter++; // Update the counter
}

Because this loop type is so common, there is a spe-


cial form for it, called the for loop (see Syntax 6.2).
for (int counter = 1; counter <= 10; counter++)
{
Additional full code examples }
System.out.println(counter);

provides complete programs for FULL CODE EXAMPLE Some people call this loop count-controlled. In con-
Go to wiley.com/go/ trast, the while loop of the preceding section can be
students to run and modify. bjeo6code to download
a program that
called an event-controlled loop because it executes
uses common loop until an event occurs; namely that the balance reaches
algorithms. the target. Another commonly used term for a
count-controlled loop is definite. You know from
the outset that the loop body will be executed a
definite number of times; ten times in our example.
In contrast, you do not know how many iterations it
takes to accumulate a target balance. Such a loop is
Annotated syntax boxes called indefinite. You can visualize the for loop as
an orderly sequence of steps.
provide a quick, visual overview
of new language constructs. Syntax 6.2 for Statement

Syntax for (initialization; condition; update)


{
statements
}
These three
expressions should be related.
See page 255.

Annotations explain required This initialization The condition is This update is


components and point to more happens once
before the loop starts .
checked before
each iteration.
executed after
each iteration.
information on common errors for (int i = 5; i <= 10; i++)
or best practices associated The v ariable i is
{
sum = sum + i; This loop executes 6 times.
with the syntax. defined only in this for loop.
See page 257.
} See page 256.

Analogies to everyday objects are


used to explain the nature and behavior
of concepts such as variables, data
Like a variable in a computer types, loops, and more.
program, a parking space has
an identifier and a contents.
x Walkthrough

Memorable photos reinforce


analogies and help students
remember the concepts.

In the same way that there can be a street named “Main Street” in different cities,
a Java program can have multiple variables with the same name.

Problem Solving sections teach


techniques for generating ideas and 7.5 Problem Solving: Discovering Algorithms by Manipulating Physical Objects 333

evaluating proposed solutions, often Now how does that help us with our problem, switching the first and the second
using pencil and paper or other half of the array?
Let’s put the first coin into place, by swapping it with the fifth coin. However, as
artifacts. These sections emphasize Java programmers, we will say that we swap the coins in positions 0 and 4:

that most of the planning and problem


solving that makes students successful
happens away from the computer.

Next, we swap the coins in positions 1 and 5:

HOW TO 6.1 Writing a Loop How To guides give step-by-step


This How To walks you through the process of implementing a guidance for common programming
loop statement. We will illustrate the steps with the following
example problem. tasks, emphasizing planning and
Problem Statement Read twelve temperature values (one for
each month) and display the number of the month with the high- testing. They answer the beginner’s
est temperature. For example, according to worldclimate.com, the
average maximum temperatures for Death Valley are (in order by question, “Now what do I do?” and
month, in degrees Celsius):
18.2 22.6 26.4 31.1 36.6 42.2 45.7 44.5 40.2 33.1 24.2 17.6
integrate key concepts into a
In this case, the month with the highest temperature (45.7 degrees problem-solving sequence.
Celsius) is July, and the program should display 7.

Step 1 Decide what work must be done inside the loop.

Every loop needs to do some kind of repetitive work, such as


• Reading another item.
• Updating a value (such as a bank balance or total).
• Incrementing a counter. Worked Examples apply
If you can’t figure out what needs to go inside the loop, start by writing down the steps that
the steps in the How To to a
WORKED EXAMPLE 6.1 Credit Card Processing different example, showing
Learn how to use a loop to remove spaces from a credit card
number. Go to wiley.com/go/bjeo6examples and download
how they can be used to
Worked Example 6.1.
plan, implement, and test
a solution to another
programming problem.
Table 1 Variable Declarations in Java
Variable Name Comment

int width = 20; Declares an integer variable and initializes it with 20.

int perimeter = 4 * width; The initial value need not be a fixed value. (Of course, width
must have been previously declared.)
String greeting = "Hi!"; This variable has the type String and is initialized with the
Example tables support beginners
string “Hi”. with multiple, concrete examples.
height = 30; Error: The type is missing. This statement is not a declaration
but an assignment of a new value to an existing variable—see These tables point out common
Section 2.2.5.
errors and present another quick
int width = "20"; Error: You cannot initialize a number with the string “20”.
(Note the quotation marks.) reference to the section’s topic.
int width; Declares an integer variable without initializing it. This can be a
cause for errors—see Common Error 2.1 on page 40.
int width, height; Declares two integer variables in a single statement. In this
book, we will declare each variable in a separate statement.
Walkthrough xi

This means “compute the value of width + 10 1 and store that value in the variable
width 2 ” (see Figure 4).
Progressive figures trace code
In Java, it is not a problem that the variable width is used on both sides of the = sym-
bol. Of course, in mathematics, the equation width = width + 10 has no solution.
segments to help students visualize
the program flow. Color is used
1 Compute the value of the right-hand side
consistently to make variables and
width = 30
other elements easily recognizable.
width + 10

40

2 Store the value in the variable Figure 3


1 Initialize counter
Execution of a for (int counter = 1; counter <= 10; counter++)
Figure 4 width = 40 for Loop {
Executing the Statement System.out.println(counter);
counter = 1 }
width = width + 10

2 Check condition
for (int counter = 1; counter <= 10; counter++)
{
System.out.println(counter);
counter = 1 }

3 Execute loop body


for (int counter = 1; counter <= 10; counter++)
{
System.out.println(counter);
counter = 1 }

4 Update counter
for (int counter = 1; counter <= 10; counter++)
{
System.out.println(counter);
counter = 2 }

5 Check condition again


for (int counter = 1; counter <= 10; counter++)
Self-check exercises at the {
System.out.println(counter);
end of each section are designed counter = 2 }

to make students think through


the new material—and can The for loop neatly groups the initialization, condition, and update expressions
together. However, it is important to realize that these expressions are not executed
spark discussion in lecture. together (see Figure 3).

• The initialization is executed once, before the loop is entered. 1


• The condition is checked before each iteration. 2 5
• The update is executed after each iteration. 4
11. Write the for loop of the Investment class as a while loop.
SELF CHECK
12. How many numbers does this loop print?
for (int n = 10; n >= 0; n--)
{
System.out.println(n);
}

13. Write a for loop that prints all even numbers between 10 and 20 (inclusive).
14. Write a for loop that computes the sum of the integers from 1 to n.

Practice It Now you can try these exercises at the end of the chapter: R6.4, R6.10, E6.8, E6.12.
Optional science and business
exercises engage students with •• Business E6.17 Currency conversion. Write a program

realistic applications of Java. that first asks the user to type today’s
price for one dollar in Japanese yen,
then reads U.S. dollar values and
converts each to yen. Use 0 as a sentinel.

• Science P6.15 Radioactive decay of radioactive materials can be


section_1/Investment.java modeled by the equation A = A0e-t (log 2/h), where A is
1 /** the amount of the material at time t, A0 is the amount
2 A class to monitor the growth of an investment that at time 0, and h is the half-life.
3 accumulates interest at a fixed annual rate.
4 */ Technetium-99 is a radioisotope that is used in imaging
5 public class Investment of the brain. It has a half-life of 6 hours. Your program
6 { should display the relative amount A / A0 in a patient
7 private double balance; body every hour for 24 hours after receiving a dose.
8 private double rate;
9 private int year;
10
11 /**
12 Constructs an Investment object from a starting balance and
13 interest rate.
14 @param aBalance the starting balance
15
16 */
@param aRate the interest rate in percent
Program listings are carefully
17 public Investment(double aBalance, double aRate)
18 { designed for easy reading,
19 balance = aBalance;
20
21
rate = aRate;
year = 0;
going well beyond simple
22
23
}
color coding. Methods are set
24
25
/**
Keeps accumulating interest until a target balance has off by a subtle outline.
26 been reached.
27 @param targetBalance the desired balance
28 */
xii Walkthrough

Length and Size


Common Errors describe the kinds Common Error 7.4
Unfortunately, the Java syntax for Data Type Number of Elements
of errors that students often make, determining the number of elements
in an array, an array list, and a string Array a.length
with an explanation of why the errors is not at all consistent. It is a com-
mon error to confuse these. You just Array list a.size()

occur, and what to do about them. have to remember the correct syntax
for every data type. String a.length()

Programming Tip 5.5 Hand-Tracing


A very useful technique for understanding whether a pro-
gram works correctly is called hand-tracing. You simulate
the program’s activity on a sheet of paper. You can use this
method with pseudocode or Java code.
Get an index card, a cocktail napkin, or whatever sheet
of paper is within reach. Make a column for each variable.
Have the program code ready. Use a marker, such as a
paper clip, to mark the current statement. In your mind,
execute statements one at a time. Every time the value of a
variable changes, cross out the old value and write the new
value below the old one. Hand-tracing helps you
For example, let’s trace the getTax method with the data understand whether a
Programming Tips explain from the program run above.
When the TaxReturn object is constructed, the income
program works correctly.

good programming practices, instance variable is set to 80,000 and status is set to MARRIED. Then the getTax method is called.
In lines 31 and 32 of TaxReturn.java, tax1 and tax2 are initialized to 0.
and encourage students to be 29 public double getTax()
30 {

more productive with tips and income status tax1 tax2


31 double tax1 = 0;
32 double tax2 = 0;
33 80000 MARRIED 0 0
techniques such as hand-tracing. Because status is not SINGLE, we move to the else
branch of the outer if statement (line 46).
34 if (status == SINGLE)
35 {
36 if (income <= RATE1_SINGLE_LIMIT)
37 {
38 tax1 = RATE1 * income;
39 }
40 else
41 {
42 tax1 = RATE1 * RATE1_SINGLE_LIMIT;
43 tax2 = RATE2 * (income - RATE1_SINGLE_LIMIT);
44 }
45 }
46 else
47 {

Special Topic 11.2 File Dialog Boxes


In a program with a graphical user interface, you will want to use a file dialog box (such as the
one shown in the figure below) whenever the users of your program need to pick a file. The
JFileChooser class implements a file dialog box for the Swing user-interface toolkit.
The JFileChooser class has many options to fine-tune the display of the dialog box, but in its
Special Topics present optional most basic form it is quite simple: Construct a file chooser object; then call the showOpenDialog
or showSaveDialog method. Both methods show the same dialog box, but the button for select-
topics and provide additional ing a file is labeled “Open” or “Save”, depending on which method you call.
For better placement of the dialog box on the screen, you can specify the user-interface
explanation of others. component over which to pop up the dialog box. If you don’t care where the dialog box pops
up, you can simply pass null. The showOpenDialog and showSaveDialog methods return either
JFileChooser.APPROVE_OPTION, if the user has chosen a file, or JFileChooser.CANCEL_OPTION, if the
user canceled the selection. If a file was chosen, then you call the getSelectedFile method to
obtain a File object that describes the file. Here is a complete example:
JFileChooser chooser = new JFileChooser();
Scanner in = null;
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
{

Java 8 Note 10.4 Lambda ExpressionsFile selectedFile = chooser.getSelectedFile();


in = new Scanner(selectedFile);
In the preceding. section,
. . you saw how to use interfaces for specifying variations in behavior.
The average method
} needs to measure each object, and it does so by calling the measure method
of the supplied Measurer object.
Unfortunately, the caller of the average method has to do a fair amount of work; namely,
to define a class that implements the Measurer interface and to construct an object of that class.
Java 8 has a convenient shortcut for these steps, provided that the interface has a single abstract
Java 8 Notes provide detail method. Such an interface is called a functional interface because its purpose is to define a
single function. The Measurer interface is an example of a functional interface.
about new features in Java 8. To specify that single function, you can use a lambda expression, an expression that defines
the parameters and return value of a method in a compact notation. Here is an example:
(Object obj) -> ((BankAccount) obj).getBalance()
This expression defines a function that, given an object, casts it to a BankAccount and returns the
balance.
(The term “lambda expression” comes from a mathematical notation that uses the Greek
letter lambda (λ) instead of the -> symbol. In other programming languages, such an expres-
sion is called a function expression.)
Computing
A lambda expression cannot stand& Society
alone. 1.1
It needs to Computers
be assigned Are
to a variable Everywhere
whose type is
a functional interface:
When computers Button
The is “Save”
advent when
of ubiqui-
Measurer accountMeas
were =first
(Object obj) -> tous
invented ((BankAccount)
showSaveDialog obj).getBalance();
computing changedmethod
in the 1940s, a computer filled an many aspects is calledof our
entire room. The photo below shows lives. Factories used
the ENIAC (electronic numerical inte- to employ people to
grator and computer),A JFileChooser
completed Dialog
in doBoxrepetitive assembly
1946 at the University of Pennsylvania. tasks that are today car-
The ENIAC was used by the military ried out by computer-
Computing & Society presents social to compute the trajectories of projec- controlled robots, oper-
tiles. Nowadays, computing facilities ated by a few people

and historical topics on computing—for of search engines, Internet shops, and who know how to work
social networks fill huge buildings with those computers.

interest and to fulfill the “historical and


called data centers. At the other end of Books, music, and mov-
the spectrum, computers are all around ies are nowadays often
us. Your cell phone has a computer consumed on com- This transit card contains a computer.
social context” requirements of the inside, as do many credit cards and fare puters, and comput-
cards for public transit. A modern car ers are almost always
ACM/IEEE curriculum guidelines. has several computers––to control the involved in their production. The
engine, brakes, lights, and the radio. book that you are reading right now
could not have been written without
computers.
Acknowledgments xiii

Acknowledgments
Many thanks to Bryan Gambrel, Don Fowley, Jenny Welter, Jessy Moor, Jennifer
Lartz, Billy Ray, and Tim Lindner at John Wiley & Sons, and Vickie Piercey at Pub-
lishing Services for their help with this project. An especially deep acknowledgment
and thanks goes to Cindy Johnson for her hard work, sound judgment, and amazing
attention to detail.
I am grateful to Jose Cordova, The University of Louisiana at Monroe, Suzanne
Dietrich, Arizona State University,West Campus, Mike Domaratzki, University of
Manitoba, Guy Helmer, Iowa State University, Peter Lutz, Rochester Institute of
Technology, Carolyn Schauble, Colorado State University, Brent Seales, University
of Kentucky, and Brent Wilson, George Fox University for their excellent contribu-
tions to the supplementary materials.
Many thanks to the individuals who reviewed the manuscript for this edition,
made valuable suggestions, and brought an embarrassingly large number of errors
and omissions to my attention. They include:
Robin Carr, Drexel University
Gerald Cohen, The Richard Stockton College of New Jersey
Aaron Keen, California Polytechnic State University, San Luis Obispo
Aurelia Smith, Columbus State University
Aakash Taneja, The Richard Stockton College of New Jersey
Craig Tanis, University of Tennessee at Chattanooga
Katherine Winters, University of Tennessee at Chattanooga
Every new edition builds on the suggestions and experiences of prior reviewers and
users. I am grateful for the invaluable contributions these individuals have made:

Eric Aaron, Wesleyan University John Bundy, DeVry University Lennie Cooper, Miami Dade College
James Agnew, Anne Arundel Chicago Jose Cordova, University of
Community College Robert P. Burton, Brigham Young Louisiana, Monroe
Tim Andersen, Boise State University Valentino Crespi, California State
University Frank Butt, IBM University, Los Angeles
Ivan Bajic, San Diego State Jerry Cain, Stanford University Jim Cross, Auburn University
University Adam Cannon, Columbia Russell Deaton, University
Greg Ballinger, Miami Dade College University of Arkansas
Ted Bangay, Sheridan Institute Michael Carney, Finger Lakes Geoffrey Decker, Northern Illinois
of Technology Community College University
Ian Barland, Radford University Christopher Cassa, Massachusetts H. E. Dunsmore, Purdue University
George Basham, Franklin University Institute of Technology Robert Duvall, Duke University
Jon Beck, Truman State University Nancy Chase, Gonzaga University Sherif Elfayoumy, University of
Sambit Bhattacharya, Fayetteville Dr. Suchindran S. Chatterjee, North Florida
State University Arizona State University Eman El-Sheikh, University of
Rick Birney, Arizona State Archana Chidanandan, Rose- West Florida
University Hulman Institute of Technology Henry A. Etlinger, Rochester
Paul Bladek, Edmonds Community Vincent Cicirello, The Richard Institute of Technology
College Stockton College of New Jersey John Fendrich, Bradley University
Matt Boutell, Rose-Hulman Teresa Cole, Boise State University David Freer, Miami Dade College
Institute of Technology Deborah Coleman, Rochester John Fulton, Franklin University
Joseph Bowbeer, Vizrea Corporation Institute of Technology David Geary, Sabreware, Inc.
Timothy A. Budd, Oregon State Tina Comston, Franklin University Margaret Geroch, Wheeling Jesuit
University University
xiv Acknowledgments

Ahmad Ghafarian, North Georgia Joan McGrory, Christian Brothers John Santore, Bridgewater State
College & State University University College
Rick Giles, Acadia University Carolyn Miller, North Carolina Javad Shakib, DeVry University
Stacey Grasso, College of San Mateo State University Carolyn Schauble, Colorado State
Jianchao Han, California State Sandeep R. Mitra, State University University
University, Dominguez Hills of New York, Brockport Brent Seales, University of Kentucky
Lisa Hansen, Western New England Teng Moh, San Jose State University Christian Shin, SUNY Geneseo
College Bill Mongan, Drexel University Charlie Shu, Franklin University
Elliotte Harold John Moore, The Citadel Jeffrey Six, University of Delaware
Eileen Head, Binghamton Jose-Arturo Mora-Soto, Jesica Don Slater, Carnegie Mellon
University Rivero-Espinosa, and Julio-Angel University
Cecily Heiner, University of Utah Cano-Romero, University Ken Slonneger, University of Iowa
Guy Helmer, Iowa State University of Madrid Donald Smith, Columbia College
Ed Holden, Rochester Institute Faye Navabi, Arizona State Joslyn A. Smith, Florida
of Technology University International University
Brian Howard, Depauw University Parviz Partow-Navid, California Stephanie Smullen, University of
Lubomir Ivanov, Iona College State University, Los Angeles Tennessee, Chattanooga
Norman Jacobson, University of George Novacky, University Robert Strader, Stephen F. Austin
California, Irvine of Pittsburgh State University
Steven Janke, Colorado College Kevin O’Gorman, California Monica Sweat, Georgia Institute
Curt Jones, Bloomsburg University Polytechnic State University, San of Technology
Luis Obispo Peter Stanchev, Kettering University
Mark Jones, Lock Haven University
of Pennsylvania Michael Olan, Richard Stockton Shannon Tauro, University of
College California, Irvine
Dr. Mustafa Kamal, University of
Central Missouri Mimi Opkins, California State Ron Taylor, Wright State University
University Long Beach
Mugdha Khaladkar, New Jersey Russell Tessier, University of
Institute of Technology Derek Pao, City University of Massachusetts, Amherst
Hong Kong
Gary J. Koehler, University of Jonathan L. Tolstedt, North Dakota
Florida Kevin Parker, Idaho State University State University
Elliot Koffman, Temple University Jim Perry, Ulster County David Vineyard, Kettering
Community College University
Ronald Krawitz, DeVry University
Cornel Pokorny, California Joseph Vybihal, McGill University
Norm Krumpe, Miami University
Polytechnic State University,
Ohio Xiaoming Wei, Iona College
San Luis Obispo
Jim Leone, Rochester Institute Jonathan S. Weissman, Finger Lakes
Roger Priebe, University of Texas,
of Technology Community College
Austin
Kevin Lillis, St. Ambrose University Todd Whittaker, Franklin University
C. Robert Putnam, California State
Darren Lim, Siena College University, Northridge Robert Willhoft, Roberts Wesleyan
Hong Lin, DeVry University College
Kai Qian, Southern Polytechnic
Kathy Liszka, University of Akron State University Lea Wittie, Bucknell University
Hunter Lloyd, Montana State Cyndi Rader, Colorado School David Womack, University of Texas
University of Mines at San Antonio
Youmin Lu, Bloomsburg University Neil Rankin, Worcester Polytechnic David Woolbright, Columbus State
Kuber Maharjan, Purdue University Institute University
College of Technology at Brad Rippe, Fullerton College Tom Wulf, University of Cincinnati
Columbus Pedro I. Rivera Vega, University Catherine Wyman, DeVry
John S. Mallozzi, Iona College of Puerto Rico, Mayaguez University
John Martin, North Dakota State Daniel Rogers, SUNY Brockport Arthur Yanushka, Christian Brothers
University University
Chaman Lal Sabharwal, Missouri
Jeanna Matthews, Clarkson University of Science and Qi Yu, Rochester Institute of
University Technology Technology
Patricia McDermott-Wells, Florida Katherine Salch, Illinois Central Salih Yurttas, Texas A&M University
International University College
Scott McElfresh, Carnegie Mellon
University
CONTENTS

PREFACE iii 2.5 Accessor and Mutator Methods  48


SPECIAL FEATURES xxiv 2.6 The API Documentation  50
Browsing the API Documentation   50
Packages  52
1 INTRODUCTION 1
2.7 Implementing a Test Program  53
1.1 Computer Programs   2 ST1 Testing Classes in an Interactive
1.2 The Anatomy of a Computer   3 Environment 54
WE1 How Many Days Have You Been Alive?
1.3 The Java Programming Language   6 © Alex Slobodkin/iStoc
WE2 Working with Pictures
1.4 Becoming Familiar with Your © Alex Slobodkin/iStockphoto.
2.8 Object References  55
Programming Environment   7
2.9 Graphical Applications  59
1.5 Analyzing Your First Program   11
Frame Windows  59
1.6 Errors  14 Drawing on a Component   60
1.7 PROBLEM SOLVING Algorithm Design   15 Displaying a Component in a Frame   63
The Algorithm Concept   16 2.10 Ellipses, Lines, Text, and Color  64
An Algorithm for Solving an Investment Ellipses and Circles   64
Problem  17
Lines  65
Pseudocode  18
Drawing Text  65
From Algorithms to Programs   18
Colors  66
HT1 Describing an Algorithm with
Pseudocode 19
WE1 Writing an Algorithm for Tiling a Floor 21 3 IMPLEMENTING CLASSES 79
3.1 Instance Variables and Encapsulation  80
2 USING OBJECTS 31 Instance Variables  80
The Methods of the Counter Class   82
2.1 Objects and Classes  32
Encapsulation  82
Using Objects  32
Classes  33 3.2 Specifying the Public Interface
of a Class  84
2.2 Variables  34
Specifying Methods  84
Variable Declarations  34
Specifying Constructors  85
Types  36
Using the Public Interface   87
Names  37
Commenting the Public Interface   87
Comments  38
Assignment  38 3.3 Providing the Class Implementation  91
Providing Instance Variables   91
2.3 Calling Methods  41
Providing Constructors  92
The Public Interface of a Class   41
Providing Methods  93
Method Arguments  42
HT1 Implementing a Class 96
Return Values  43
WE1 Making a Simple Menu
Method Declarations  45
© Alex Slobodkin/iStockphoto.
2.4 Constructing Objects  46 3.4 Unit Testing  100

xv
xvi Contents

3.5 PROBLEM SOLVING Tracing Objects  103 5 DECISIONS 177


3.6 Local Variables  105
5.1 The if Statement   178
3.7 The this Reference  107
ST1 The Conditional Operator 182
ST1 Calling One Constructor from Another 110
5.2 Comparing Values   183
3.8 Shape Classes  110
Relational Operators  184
HT2 Drawing Graphical Shapes 114
Comparing Floating-Point Numbers   185
Comparing Strings  186
4 FUNDAMENTAL DATA Comparing Objects  187
TYPES 129 Testing for null  187
HT1 Implementing an if Statement 190
4.1 Numbers  130 WE1 Extracting the Middle
Number Types  130 © Alex Slobodkin/iStockphoto.
5.3 Multiple Alternatives   193
Constants  132 ST2 The switch Statement 196
ST1 Big Numbers 136
5.4 Nested Branches   196
4.2 Arithmetic  137 ST3 Block Scope 201
Arithmetic Operators  137 ST4 Enumeration Types 203
Increment and Decrement   138
5.5 PROBLEM SOLVING Flowcharts   203
Integer Division and Remainder   138
Powers and Roots   139 5.6 PROBLEM SOLVING Selecting Test
Converting Floating-Point Numbers Cases  206
to Integers  140 ST5 Logging 208
J81 Avoiding Negative Remainders 143
5.7 Boolean Variables and Operators   209
ST2 Combining Assignment and Arithmetic 143
ST6 Short-Circuit Evaluation of Boolean
ST3 Instance Methods and Static Methods 143 Operators 213
4.3 Input and Output   145 ST7 De Morgan’s Law 213
Reading Input    145 5.8 APPLICATION Input Validation   214
Formatted Output  146
HT1 Carrying Out Computations 149
WE1 Computing the Volume and Surface Area of
6 LOOPS 237
a Pyramid
© Alex Slobodkin/iStockphoto.
6.1 The while Loop   238
4.4 PROBLEM SOLVING First Do it By Hand   152
6.2 PROBLEM SOLVING Hand-Tracing   245
WE2 Computing Travel Time
© Alex Slobodkin/iStockphoto.6.3 The for Loop   250
4.5 Strings  154
ST1 Variables Declared in a for Loop
The String Type  154 Header 257
Concatenation  155
String Input  155 6.4 The do Loop   258
Escape Sequences  156 6.5 APPLICATION Processing Sentinel
Strings and Characters   156 Values  259
Substrings  157 ST2 Redirection of Input and Output 262
ST4 Using Dialog Boxes for Input and ST3 The “Loop and a Half” Problem 262
Output 160 ST4 The break and continue Statements 263

6.6 PROBLEM SOLVING Storyboards   265


6.7 Common Loop Algorithms   268
Sum and Average Value   268
Counting Matches  268
Contents xvii

Finding the First Match   269 7.6 Two-Dimensional Arrays  336


Prompting Until a Match is Found   270 Declaring Two-Dimensional Arrays   336
Maximum and Minimum   270 Accessing Elements  337
Comparing Adjacent Values   271 Locating Neighboring Elements   338
HT1 Writing a Loop 272 Accessing Rows and Columns   338
WE1 Credit Card Processing WE2 A World Population Table
© Alex Slobodkin/iStockphoto. © Alex Slobodkin/iStockphoto.
6.8 Nested Loops   275 ST3 Two-Dimensional Arrays with Variable
WE2 Manipulating the Pixels in an Image Row Lengths 341
ST4 Multidimensional Arrays
© Alex Slobodkin/iStockphoto. 343
6.9 APPLICATION Random Numbers and
Simulations  279 7.7 Array Lists  343
Generating Random Numbers   279 Declaring and Using Array Lists   344
The Monte Carlo Method   281 Using the Enhanced for Loop with
Array Lists  345
6.10 Using a Debugger  282 Copying Array Lists   346
HT2 Debugging 285 Wrappers and Auto-boxing   347
WE3 A Sample Debugging Session Using Array Algorithms with Array Lists   348
© Alex Slobodkin/iStockphoto. Storing Input Values in an Array List   348

Removing Matches  348
7 ARRAYS AND ARRAY Choosing Between Array Lists and Arrays   349
LISTS 307 ST5 The Diamond Syntax 352

7.1 Arrays  308 7.8 Regression Testing  352


Declaring and Using Arrays   308
Array References  311
8 DESIGNING CLASSES 375
Using Arrays with Methods   312
Partially Filled Arrays   312 8.1 Discovering Classes   376
ST1 Methods with a Variable Number of
8.2 Designing Good Methods   377
Arguments 315
Providing a Cohesive Public Interface   377
7.2 The Enhanced for Loop  317 Minimizing Dependencies  378
7.3 Common Array Algorithms  318 Separating Accessors and Mutators   379
Filling  318 Minimizing Side Effects   380
Sum and Average Value   319 ST1 Call by Value and Call by Reference 382
Maximum and Minimum   319 8.3 PROBLEM SOLVING Patterns for
Element Separators  319
Object Data   386
Linear Search  320
Keeping a Total   386
Removing an Element   320
Counting Events  387
Inserting an Element   321
Collecting Values  387
Swapping Elements  322
Managing Properties of an Object   388
Copying Arrays  323
Modeling Objects with Distinct States   388
Reading Input  324
Describing the Position of an Object   389
ST2 Sorting with the Java Library 327
8.4 Static Variables and Methods   391
7.4 PROBLEM SOLVING Adapting
ST2 Alternative Forms of Instance and Static
Algorithms  327 Variable Initialization 394
HT1 Working with Arrays 330
ST3 Static Imports 395
WE1 Rolling the Dice
© Alex Slobodkin/iStockphoto. 8.5 PROBLEM SOLVING Solve a Simpler
7.5 PROBLEM SOLVING Discovering Algorithms by
Problem First   395
Manipulating Physical Objects  332
xviii Contents

8.6 Packages  400 10.2 Working with Interface Variables   475


Organizing Related Classes into Pack­ages   400 Converting from Classes to Interfaces   475
Importing Packages  401 Invoking Methods on Interface Variables   476
Package Names  401 Casting from Interfaces to Classes    476
Packages and Source Files   402 WE1 Investigating Number Sequences
ST4 Package Access 403 © Alex Slobodkin/iStockphoto.
10.3 The Comparable Interface   477
HT1 Programming with Packages 404 ST2 The clone Method and the Cloneable
8.7 Unit Test Frameworks   405 Interface 479
10.4 Using Interfaces for Callbacks   482
9 INHERITANCE 423 J84 Lambda Expressions 485
ST3 Generic Interface Types 486
9.1 Inheritance Hierarchies   424 10.5 Inner Classes   487
9.2 Implementing Subclasses   428 ST4 Anonymous Classes 488
9.3 Overriding Methods   433 10.6 Mock Objects   489
ST1 Calling the Superclass Constructor 438 10.7 Event Handling   490
9.4 Polymorphism  439 Listening to Events   491
ST2 Dynamic Method Lookup and the Implicit Using Inner Classes for Listeners   493
Parameter 442 J85 Lambda Expressions for Event Handling 496
ST3 Abstract Classes 443
10.8 Building Applications with Buttons   496
ST4 Final Methods and Classes 444
ST5 Protected Access 444 10.9 Processing Timer Events   499
HT1 Developing an Inheritance Hierarchy 445 10.10 Mouse Events   502
WE1 Implementing an Employee Hierarchy for ST5 Keyboard Events 506
Payroll Processing ST6 Event Adapters 506
© Alex Slobodkin/iStockphoto.
9.5 Object: The Cosmic Superclass   450
Overriding the toString Method    450 11 INPUT/OUTPUT AND
The equals Method  452 EXCEPTION HANDLING 519
The instanceof Operator  453
ST6 Inheritance and the toString Method 455 11.1 Reading and Writing Text Files   520
ST7 Inheritance and the equals Method 456 ST1 Reading Web Pages 523
ST2 File Dialog Boxes 523
ST3 Character Encodings 524
10 INTERFACES 465
11.2 Text Input and Output   525
10.1 Using Interfaces for Algorithm Reading Words  525
Reuse  466 Reading Characters  526
Discovering an Interface Type   466 Classifying Characters  526
Declaring an Interface Type   467 Reading Lines  527
Implementing an Interface Type   469 Scanning a String   528
Comparing Interfaces and Inheritance   471 Converting Strings to Numbers   528
ST1 Constants in Interfaces 473 Avoiding Errors When Reading Numbers   529
J81 Static Methods in Interfaces 473 Mixing Number, Word, and Line Input   529
J82 Default Methods 473 Formatting Output  530
J83 Conflicting Default Methods 474 ST4 Regular Expressions 532
ST5 Reading an Entire File 533
Contents xix

11.3 Command Line Arguments   533 13.3 The Efficiency of Recursion   604
HT1 Processing Text Files 536 13.4 Permutations  609
WE1 Analyzing Baby Names
© Alex Slobodkin/iStockphoto.
13.5 Mutual Recursion   614
11.4 Exception Handling   540
13.6 Backtracking  620
Throwing Exceptions  540
WE2 Towers of Hanoi
Catching Exceptions  542 © Alex Slobodkin/iStockphoto.
Checked Exceptions  543
Closing Resources  545 14 SORTING AND
Designing Your Own Exception Types   546 SEARCHING 635
ST6 Assertions 549
ST7 The try/finally Statement 549 14.1 Selection Sort   636
11.5 APPLICATION Handling Input Errors   549 14.2 Profiling the Selection Sort
Algorithm  639
14.3 Analyzing the Performance of the
12 OBJECT-ORIENTED
Selection Sort Algorithm   642
DESIGN 565
ST1 Oh, Omega, and Theta 644
12.1 Classes and Their Responsibilities   566 ST2 Insertion Sort 645
Discovering Classes  566 14.4 Merge Sort   647
The CRC Card Method   567
14.5 Analyzing the Merge Sort Algorithm   650
12.2 Relationships Between Classes   569 ST3 The Quicksort Algorithm 652
Dependency  569 14.6 Searching  654
Aggregation  570
Linear Search  654
Inheritance  571
Binary Search  655
HT1 Using CRC Cards and UML Diagrams in
Program Design 572 14.7 PROBLEM SOLVING Estimating the Running
ST1 Attributes and Methods in UML Time of an Algorithm   659
Diagrams 573 Linear Time  659
ST2 Multiplicities 574 Quadratic Time  660
ST3 Aggregation, Association, and The Triangle Pattern   661
Composition 574 Logarithmic Time  662
12.3 APPLICATION Printing an Invoice   575 14.8 Sorting and Searching in the Java
Requirements  575 Library  664
CRC Cards  576 Sorting  664
UML Diagrams  578 Binary Search  664
Method Documentation  579 Comparing Objects  665
Implementation  581 ST4 The Comparator Interface 666
WE1 Simulating an Automatic Teller Machine J81 Comparators with Lambda Expressions 667
© Alex Slobodkin/iStockphoto.
WE1 Enhancing the Insertion Sort Algorithm
© Alex Slobodkin/iSt
13 RECURSION 593
15 THE JAVA COLLECTIONS
13.1 Triangle Numbers   594
FRAMEWORK 677
HT1 Thinking Recursively 599
WE1 Finding Files 15.1 An Overview of the Collections
© Alex Slobodkin/iStockphoto.
13.2 Recursive Helper Methods   602 Framework  678
Discovering Diverse Content Through
Random Scribd Documents
should Anderson request them, or should it be known from any
other quarter that Fort Sumter was in danger of attack. Congress
might not, as it did not, assume any part of its just responsibility;
and it was not known until some days after the termination of Major
Anderson’s truce, on the 6th of February, that the Governor of South
Carolina had determined to respect the wishes of the Virginia
Legislature, and refrain from attacking the fort while the Peace
Convention was sitting.[142]
Without waiting to know how Congress might treat this proposal
of the Virginia General Assembly, the President, on the 30th of
January, addressed the following note to the Secretary of War, Mr.
Holt:

Washington, January 30th, 1861.


My Dear Sir:—
It is time we should have decided whether it is practicable with
the means in our power, considering the obstacles interposed in the
harbor of Charleston, to reinforce Major Anderson at Fort Sumter,
should the action of the authorities of South Carolina, or his request,
render this necessary. The high military attainments and just
reputation of General Scott render his advice on this subject of the
greatest importance. Should reinforcements be deemed practicable,
then, in consultation with him, a plan ought to be devised in
advance to accomplish the object. I should be gratified to see
General Scott, the Secretary of the Navy, and yourself, at twelve
o’clock to-day, or any other hour most convenient to yourselves, to
talk over this and other matters.
Your friend very respectfully,
James Buchanan.

The result of the conference appointed by this note has been


given by Mr. Buchanan himself:

After several consultations, an expedition for this purpose was


quietly prepared at New York, under the direction of Secretary
Toucey, for the relief of Fort Sumter, the command of which was
intrusted to his intimate friend, the late lamented Commander Ward
of the navy. This gallant officer had been authorized to select his
own officers and men, who were to rendezvous on board the
receiving-ship, of which he was then in command. The expedition
consisted of a few small steamers, and it was arranged that on
receiving a telegraphic despatch from the Secretary, whenever the
emergency might require, he should, in the course of the following
night, set sail for Charleston, entering the harbor in the night, and
anchoring if possible under the guns of Fort Sumter.
It is due to the memory of this brave officer to state that he had
sought the enterprise with the greatest enthusiasm, and was willing
to sacrifice his life in the accomplishment of the object, should such
be his fate, saying to Secretary Toucey, this would be the best
inheritance he could leave to his wife and children.[143]

This expedition did not sail. It consisted of a few small vessels


borrowed from the Treasury Department, with two or three hundred
men. While it was preparing, the Peace Convention was in session;
and as it had become known to the President that the authorities of
South Carolina were then respecting the appeal of the General
Assembly of Virginia to avoid collision, it would have broken up the
Peace Convention to send reinforcements to Major Anderson, unless
he asked for them; and it would inevitably have led to an immediate
assault upon the fort, which would have been the signal for a civil
war. These considerations caused some delay in issuing the orders to
Commander Ward. In point of fact, Major Anderson not only did not
ask for reinforcements, but on the 30th of January, the day on which
the President summoned the Secretaries of War and the Navy and
General Scott to a conference, Anderson wrote to the War
Department that he hoped no attempt would be made to throw in
supplies; that it would do more harm than good. From later advices
received from him, it became apparent that this small expedition
under Commander Ward could not enter the harbor of Charleston
without a fearful sacrifice of life. It was therefore kept back, but kept
in readiness, at New York, until the 5th day of March, on which day
President Lincoln was fully informed of it, and of the circumstances
which had prevented its sailing, by the retiring Secretary of War, Mr.
Holt, with the concurrence of President Buchanan.
Without anticipating, however, what occurred on the last day of
Mr. Buchanan’s administration, and on the day following, it is only
needful to say here that Fort Sumter remained unmolested by any
actual attack, until some time after Mr. Lincoln’s inauguration,
although the disposition of the authorities of South Carolina
continued to be as hostile as ever. On the 4th of February, a
Congress of the States which had then seceded was held at
Montgomery in Alabama. These were the States of South Carolina,
Mississippi, Florida, Alabama, Georgia and Louisiana. The delegates
to this Congress were appointed by conventions of their respective
States. This body framed a provisional constitution for the new
Confederacy, which they styled the “Confederate States of America.”
It was adopted by the Congress on the 8th of February, and was to
continue in force for one year, unless it should be superseded at an
earlier period by a permanent organization. Jefferson Davis was
elected President, and Alexander H. Stephens Vice President, of the
new Confederacy. No popular election of Congress was ordered, but
the legislative powers were vested “in this Congress now assembled,
until otherwise ordered.”[144]
The authorities of South Carolina immediately began to look to the
Montgomery government for direction. On the 14th of February, a
telegraph operator in Augusta, Georgia, transmitted a despatch from
Charleston to Montgomery, urging the Southern Congress to do
something definite in regard to Fort Sumter, and asking whether the
Congress would appoint a General to lead the attack, or whether it
should be done under the superintendence of Governor Pickens, who
said, “the fort must be taken before Lincoln takes his seat.”[145]
Comparing the date on which information of this despatch reached
President Buchanan (February 19th), with what was taking place in
Washington at that time, it will appear that the administration could
not, while the Peace Congress was still in session, do anything more
than to prepare secretly the small expedition under Commander
Ward, and hold it in readiness to sail, whenever Major Anderson
should signify that he considered his position as insecure. From
information which reached the President from other quarters, he was
satisfied that the Montgomery Congress would not approve of the
taking of Fort Sumter before Mr. Lincoln’s inauguration. The great
body of the persons composing the Montgomery government were
too cool and too wary in their plans to promote, at that time, the
hasty and hot-headed schemes of their friends in South Carolina.
They were still bent upon procuring the peaceable assent of the
Federal Government to the separation of their States from the Union.
[146]

They did not mean to initiate a war, although most of them saw
clearly that there would be war, while they denied that there ought
to be one. At all events, they meant to have it appear to the world
that they had done everything they could to procure a peaceable
acquiescence in their secession from the Union. Under these
circumstances, President Buchanan, who now had less than three
weeks of his official term remaining, and who could not anticipate
that commissioners of the new Confederacy would reach Washington
while he was President (they were not appointed until the 25th of
February), could only leave the position of things in regard to Fort
Sumter in the best possible attitude for his successor. This attitude
was, to hold privately all the means that the Government then had
for relieving Fort Sumter, in readiness, to be used by his successor
as circumstances might require.
In the mean time, as the 4th of March was drawing near, Mr.
Lincoln, the President-elect, was making his journey from Springfield
towards Washington, delivering public speeches on the way, the
tenor of which was that retaining the forts and other property of the
United States in the seceded States was not coercion, that there
need be no war, and that there was no occasion for any alarm, as
“nobody was hurt.” From these strange utterances of Mr. Lincoln, as
he approached the capital, the only inference that could be drawn
was that he considered the country to be in no danger, and that
there would be no occasion to use force. It has been claimed, and
not without some reason, that Mr. Lincoln’s speeches on this journey
encouraged the secessionists to believe that they could negotiate a
peaceable and final separation of their States from the Union. But at
all events, Mr. Lincoln’s travelling speeches justified the course that
had been pursued by Mr. Buchanan; for Mr. Lincoln’s attitude as the
incoming President was that the use of force must be confined to
the preservation of the property of the United States in the seceded
States, against all attempts to forcibly dispossess the Federal
Government. How the war was precipitated, after Mr. Lincoln’s
inauguration, is a distinct topic. On the day of his inauguration, he
was perfectly at liberty, so far as depended upon anything done or
forborne by his predecessor, to refuse all communication with the
Montgomery commissioners, and to use all the means that his
predecessor had ever had for reinforcing Fort Sumter. He was
doubtless surprised, as his predecessor was, by being informed on
the 5th day of March, that Fort Sumter could not be held without a
force of fifteen or twenty thousand men, to destroy the batteries
that had been erected around it; and had the Congress, which
expired on the day of his inauguration, made the provisions for the
emergency which Mr. Buchanan urged upon them, no member of Mr.
Lincoln’s administration would have had any occasion to temporize
with the Southern commissioners in any form, concerning the
retention of that fortress.
And here it may be well to recapitulate distinctly what President
Buchanan urged Congress to do and what it neglected to do. He has
himself so clearly stated this, that I cannot do better than to quote
his words:

We have already seen that Congress, throughout the entire


session, refused to adopt any measures of compromise to prevent
civil war, or to retain first the cotton or afterwards the border States
within the Union. Failing to do this, and whilst witnessing the
secession of one after another of the cotton States, the withdrawal
of their Senators and Representatives, and the formation of their
Confederacy, it was the imperative duty of Congress to furnish the
President or his successor the means of repelling force by force,
should this become necessary, to preserve the Union. They,
nevertheless, refused to perform this duty, with as much pertinacity
as they had manifested in repudiating all measures of compromise.
1. At the meeting of Congress, a Federal Judiciary had ceased to
exist in South Carolina. The District Judge, the District Attorney, and
the United States Marshal had resigned their offices. These ministers
of justice had all deserted their posts before the act of secession,
and the laws of the United States could no longer be enforced
through their agency. We have already seen that the President, in
his message, called the attention of Congress to this subject, but no
attempt was made in either House to provide a remedy for the evil.
2. Congress positively refused to pass a law conferring on the
President authority to call forth the militia, or accept the services of
volunteers, to suppress insurrections which might occur in any State
against the Government of the United States. It may appear strange
that this power had not long since been vested in the Executive. The
Act of February 28, 1795,[147] the only law applicable to the subject,
provides alone for calling forth the militia to suppress insurrections
against State governments, without making any similar provision for
suppressing insurrections against the Government of the United
States. If anything were required beyond a mere inspection of the
act to render this clear, it may be found in the opinion of Attorney
General Black, of the 20th November, 1860. Indeed, it is a plain
casus omissus. This palpable omission, which ought to have been
instantly supplied, was suffered to continue until after the end of Mr.
Buchanan’s administration, when on the 29th July, 1861, Congress
conferred this necessary power on the President.[148] The framers of
the Act of 1795 either did not anticipate an insurrection within any
State against the Federal Government, or if they did, they purposely
abstained from providing for it. Even in regard to insurrections
against a State government, so jealous were they of any
interference on the part of the Federal Government with the rights of
the States, that they withheld from Congress the power to protect
any State “against domestic violence,” except “on the application of
the Legislature, or of the Executive (when the Legislature cannot be
convened).” Under the Act of 1795, therefore, the President is
precluded from acting, even upon his own personal and absolute
knowledge of the existence of such an insurrection. Before he can
call forth the militia for its suppression, he must first be applied to
for this purpose by the appropriate State authorities, in the manner
prescribed by the Constitution. It was the duty of Congress,
immediately after their meeting, to supply this defect in our laws,
and to confer an absolute authority on the President to call forth the
militia, and accept the services of volunteers, to suppress
insurrections against the United States, whenever or wherever they
might occur. This was a precautionary measure which, independently
of existing dangers, ought long since to have formed a part of our
permanent legislation. But no attempt was ever made in Congress to
adopt it until after the President’s special message of the 8th
January, 1861, and then the attempt entirely failed. Meanwhile the
aspect of public affairs had become more and more threatening. Mr.
Crittenden’s amendment had been defeated before the Committee of
Thirteen, on the last day of December; and it was also highly
probable that his proposition before the Senate to refer it to a vote
of the people of the States, would share the same fate. South
Carolina and Florida had already seceded, and the other cotton
States had called conventions for the purpose of seceding. Nay,
more, several of them had already seized the forts, magazines, and
arsenals within their limits. Still all this failed to produce any effect
upon Congress. It was at this crisis the President sent his special
message to Congress (8th January, 1861), by which he endeavored
to impress them with the necessity for immediate action. He
concealed nothing from them. Whilst still clinging to the fading hope
that they might yet provide for a peaceful adjustment of our
difficulties, and strongly recommending this course, he says: “Even
now the danger is upon us. In several of the States which have not
yet seceded, the forts, arsenals, and magazines of the United States
have been seized. This is by far the most serious step which has
been taken since the commencement of the troubles...... The seizure
of this property, from all appearances, has been purely aggressive,
and not in resistance to any attempt to coerce a State or States to
remain in the Union.” He also stated the well-known fact that our
small army was on the remote frontiers, and was scarcely sufficient
to guard the inhabitants against Indian incursions, and consequently
our forts were without sufficient garrisons.
Under these circumstances he appeals to Congress in the
following language: “But the dangerous and hostile attitude of the
States toward each other has already far transcended and cast in the
shade the ordinary executive duties already provided for by law, and
has assumed such vast and alarming proportions as to place the
subject entirely above and beyond executive control. The fact cannot
be disguised that we are in the midst of a great revolution. In all its
great bearings, therefore, I commend the question to Congress, as
the only human tribunal, under Providence, possessing the power to
declare war, or to authorize the employment of military force in all
cases contemplated by the Constitution; and they alone possess the
power to remove grievances which might lead to war, and to secure
peace and union to this distracted country. On them, and on them
alone, rests the responsibility.”
Congress might, had they thought proper, have regarded the
forcible seizure of these forts and other property, including that of
the Branch Mint at New Orleans, with all the treasure it contained,
as the commencement of an aggressive war. Beyond question the
cotton States had now committed acts of open hostility against the
Federal Government. They had always contended that secession was
a peaceful constitutional remedy, and that Congress had no power to
make war against a sovereign State for the purpose of coercing her
to remain in the Union. They could no longer shelter themselves
under this plea. They had by their violent action entirely changed the
position they had assumed; and instead of peacefully awaiting the
decision of Congress on the question of coercion, they had
themselves become the coercionists and assailants. This question
had, therefore, passed away. No person has ever doubted the right
or the duty of Congress to pass laws enabling the President to
defend the Union against armed rebellion. Congress, however, still
shrunk from the responsibility of passing any such laws. This might
have been commendable had it proceeded from a sincere desire not
to interpose obstacles to a compromise intended to prevent the
effusion of fraternal blood and restore the Union. Still, in any event,
the time had arrived when it was their duty to make at the least
contingent provisions for the prosecution of the war, should this be
rendered inevitable. This had become the more necessary as
Congress would soon expire, and the new Congress could not be
convened for a considerable period after the old one had ceased to
exist, because a large portion of the Representatives had not then
been elected. These reasons, however, produced no effect.
The President’s special message[149] was referred, two days after
its date (10th January), by the House of Representatives to a special
committee, of which Mr. Howard, of Michigan, was chairman.
Nothing was heard from this committee for the space of twenty
days. They then, on the 30th January, through Mr. John H. Reynolds,
of New York, one of its members, reported a bill[150] enabling the
President to call forth the militia or to accept the services of
volunteers for the purpose of protecting the forts, magazines,
arsenals, and other property of the United States, and to “recover
possession” of such of these as “have been or may hereafter be
unlawfully seized or taken possession of by any combination of
persons whatever.” Had this bill become a law, it would have been
the duty of the President at once to raise a volunteer or militia force
to recapture the forts which had been already seized. But Congress
was not then prepared to assume such a responsibility. Mr. Reynolds
accordingly withdrew his bill from the consideration of the House on
the very day it was reported. On his own motion it was recommitted,
and thus killed as soon as it saw the light. It was never heard of
more.
Then, after another pause of nineteen days, and only a fortnight
before the close of the session, the Committee on Military Affairs,
through Mr. Stanton, of Ohio, their chairman, on the 18th February
reported another bill[151] on the subject, but of a more limited
character than that which had been withdrawn. It is remarkable that
it contains no provision touching the recovery of the forts and other
property which had been already seized by the delinquent States. It
did no more than provide that the powers already possessed by the
President, under the Act of 1795, to employ the militia in
suppressing insurrections against a State government, should be
“extended to the case of insurrections against the authority of the
United States,” with the additional authority to “accept the services
of such volunteers as may offer their services for the purpose
mentioned.” Thus all hostile action for the recovery of the forts
already seized was excluded from the bill. It is difficult to conceive
what reasonable objection could be made to this bill, except that it
did not go far enough and embrace the forts already seized; and
more especially as when it was reported we may recollect that the
Confederate Congress had already been ten days in session at
Montgomery, Alabama, and had adopted a Provisional Constitution.
Notwithstanding all this, the House refused to act upon it. The bill
was discussed on several occasions until Tuesday, 26th February. On
that day a motion was made by Mr. Corwin, of Ohio, to postpone its
consideration until Thursday, the 28th February.[152] Mr. Stanton, the
reporter of the bill, resisted this motion, stating that such a
postponement would be fatal to it. “It will,” said he, “be impossible
after that to have it passed by the Senate” (before the 4th March).
He, therefore, demanded the ayes and noes; and notwithstanding
his warning, Mr. Corwin’s motion prevailed by a vote of 100 to 74,
and thus the bill was defeated.
It may be proper to observe that Mr. Corwin, whose motion killed
the bill, was a confidential friend of the President elect, then present
in Washington, and was soon thereafter appointed minister to
Mexico.
But even had Congress passed this bill, it would have proved
wholly inefficient for want of an appropriation to carry it into effect.
The Treasury was empty; but had it been full, the President could
not have drawn from it any, even the most trifling sum, without a
previous appropriation by law. The union of the purse with the
sword, in the hands of the Executive, is wholly inconsistent with the
idea of a free government. The power of the legislative branch to
withhold money from the Executive, and thus restrain him from
dangerous projects of his own, is a necessary safeguard of liberty.
This exists in every government pretending to be free. Hence our
Constitution has declared that “no money shall be drawn from the
Treasury but in consequence of appropriations made by law.” It is,
therefore, apparent that even if this bill had become a law, it could
not have been carried into effect by the President without a direct
violation of the Constitution.
Notwithstanding these insuperable obstacles, no member of either
House, throughout the entire session, ever even proposed to raise or
appropriate a single dollar for the defence of the Government
against armed rebellion. Congress not only refused to grant the
President the authority and force necessary to suppress insurrections
against the United States, but the Senate, by refusing to confirm his
nomination of a collector of the customs for the port of Charleston,
effectually tied his hands and rendered it impossible for him to
collect the revenue within that port. In his annual message he
expressed the opinion that “the same insuperable obstacles do not
lie in the way of executing the [existing] laws for the collection of
customs on the seaboard of South Carolina as had been interposed
to prevent the administration of justice under the Federal authority
within the interior of that State.” At all events he had determined to
make the effort with the naval force under his command. He trusted
that this might be accomplished without collision; but if resisted,
then the force necessary to attain the object must be applied.
Accordingly, whilst informing Congress “that the revenue still
continues to be collected as heretofore at the custom house in
Charleston,” he says that “should the collector unfortunately resign,
a successor may be appointed to perform this duty.” The collector
(William F. Colcock) continued faithfully to perform his duties until
some days after the State had seceded, when at the end of
December he resigned. The President, immediately afterwards, on
the 2d January, nominated to the Senate, as his successor, Mr. Peter
McIntire, of Pennsylvania, a gentleman well qualified for the office.
The selection could not have been made from South Carolina,
because no citizen of that State would have accepted the
appointment. The Senate, throughout their entire session, never
acted upon the nomination of Mr. McIntire; and without a collector of
customs duly appointed, it was rendered impossible for the
President, under any law in existence, to collect the revenue.
But even if the Senate had confirmed Mr. McIntire’s nomination, it
is extremely doubtful whether the President could lawfully have
collected the revenue against the forcible resistance of the State,
unless Congress had conferred additional powers upon him. For this
purpose Mr. Bingham, of Ohio, on the 3d January, 1861,[153] the day
after Mr. McIntire’s nomination to the Senate, reported a bill from
the Judiciary Committee, further to provide for the collection of
duties on imports. This bill embraced substantially the same
provisions, long since expired, contained in the Act of 2d March,
1833, commonly called “the Force Bill,” to enable General Jackson to
collect the revenue outside of Charleston, “either upon land or on
board any vessel.” Mr. Bingham’s bill was permitted to slumber on
the files of the House until the 2d March, the last day but one before
Congress expired,[154] when he moved for a suspension of the rules,
to enable the House to take it up and consider it, but his motion
proved unsuccessful. Indeed, the motion was not made until so late
an hour of the session that even if it had prevailed, the bill could not
have passed both Houses before the final adjournment. Thus the
President was left both without a collector of customs, and most
probably without any law which a collector could have carried into
effect, had such an officer existed. Mr. Bingham’s bill shared the fate
of all other legislative measures, of whatever character, intended
either to prevent or to confront the existing danger. From the
persistent refusal to pass any act enabling either the outgoing or the
incoming administration to meet the contingency of civil war, it may
fairly be inferred that the friends of Mr. Lincoln, in and out of
Congress, believed he would be able to settle the existing difficulties
with the cotton States in a peaceful manner, and that he might be
embarrassed by any legislation contemplating the necessity of a
resort to hostile measures.
The 36th Congress expired on the 3d March, 1861, leaving the law
just as they found it. They made no provision whatever for the
suppression of threatened rebellion, but deliberately refused to grant
either men or money for this purpose. It was this violation of duty
which compelled President Lincoln to issue a proclamation convening
the new Congress, in special session, immediately after the attack on
Fort Sumter.[155]
It is proper to state that President Lincoln did not accord to the
Montgomery Commissioners any official reception as representatives
of an independent government. But as will hereafter appear, his
Secretary of State, Mr. Seward, through the intervention of
distinguished persons in Washington, held much informal intercourse
with them in regard to the evacuation of Fort Sumter, the result of
which was that the commissioners left Washington believing, or
professing to believe, that they had been duped by a promise to
withdraw the troops, which had not been fulfilled, but, on the
contrary, that secret preparations were making by Mr. Lincoln’s
government to send reinforcements. This has always been assigned
as the excuse for the attack on Fort Sumter.[156]
CHAPTER XXIV.
1861—February and March.

COMMISSIONERS FROM THE CONFEDERATE GOVERNMENT—MR.


JEFFERSON DAVIS’S STATEMENT THAT THEY WERE INVITED BY
PRESIDENT BUCHANAN CALLED IN QUESTION.

It is now my duty to examine a statement made by Mr. Jefferson


Davis in his recent work, to the effect that Confederate
commissioners were appointed and sent to Washington from
Montgomery, partly, at least, in consequence of a suggestion made
to him by President Buchanan. The statement is in these words: “It
may here be mentioned, in explanation of my desire that the
commission, or at least a part of it, should reach Washington before
the close of Mr. Buchanan’s term, that I had received an intimation
from him, through a distinguished Senator of one of the border
States,[157] that he would be happy to receive a commissioner or
commissioners from the Confederate States, and would refer to the
Senate any communication that might be made through such a
commission.”[158]
This intimation, if it was ever made, was, as Mr. Davis describes it,
that the President would himself receive a diplomatic agent or
agents from the Confederate States, and would, as is the customary
and constitutional course on extraordinary occasions, consult the
Senate, not Congress, upon any communication that such agent or
agents might desire to make. Mr. Davis, although he names Mr.
Hunter, of Virginia, as the person through whom he received this
intimation, quotes no letter or telegram from that gentleman; so that
a judgment cannot be formed upon the character of this alleged
intimation. There is not the least trace among Mr. Buchanan’s private
papers of his ever having made to Mr. Hunter such a suggestion in
writing. If it was made orally—considering his habit of keeping
memoranda of important conversations, especially with the Southern
Senators—it is highly probable that he would not have omitted to
record this one. No such memorandum has been found after the
most diligent search. One is left, therefore, to the probabilities of the
case, which are all against the correctness of Mr. Davis’ statement.
No imputation is here made upon Mr. Davis’ veracity; but it evidently
requires something more in the nature of proof than anything he has
given, to justify the belief that President Buchanan ever expressed
his willingness to receive commissioners from the Confederate
States, to negotiate with the diplomatic department of the
Government for a peaceable acknowledgment of the independence
of those States. The mere reception of such commissioners and a
reference of their communication to the Senate, would have been
tantamount to an admission that the Confederate government could
be treated with as an independent power.
1. In the letter addressed by Mr. Davis to the President, dated on
the 27th of February, 1861, and which he describes in his book as
“of a personal and semi-official character,” introducing Mr. Crawford,
the first commissioner to arrive in Washington, and asking for him “a
favorable reception corresponding to his station,” he did not in any
manner signify that he was sending Mr. Crawford to Washington in
compliance with an intimation which he, Mr. Davis, had received
from Mr. Buchanan. This he would naturally have said, in such a
personal letter, if he at that time was acting upon such an intimation
from Mr. Buchanan, because it would have been an unanswerable
ground on which to ask for a favorable reception of the
commissioner. The appeal ad hominem would not have been left out
of such a letter.
2. Mr. Davis was well aware that President Buchanan had steadily
refused to accord any diplomatic or official character to the South
Carolina commissioners, as representatives of a foreign or
independent power, and that he had conferred with them only as
private and eminent citizens of their State. Mr. Davis was also aware
that the President had never offered to entertain, and had never
entertained, a proposition to refer to any other body than Congress,
the question of the standing of any seceded State. He had acted in
the same way towards Colonel Hayne, when he came from Governor
Pickens to demand the surrender of Fort Sumter; and again, early in
February, when the Hon. Thomas J. Judge presented himself as a
commissioner from the seceded State of Alabama, the President, as
Mr. Davis doubtless knew, refused to receive him in any capacity but
that of a distinguished citizen of Alabama, referring to his several
previous messages to Congress as proof that he could not recognize
Mr. Judge in the character which he claimed. All this had transpired a
good while before Mr. Davis sent Mr. Crawford to Washington. On
the other hand, ex-President Tyler had been received by the
President as a commissioner from the State of Virginia, which had
not seceded, and did not then propose and was not likely to secede
from the Union. Yet, the world is asked to believe that President
Buchanan, through a third person, sent an intimation to the
President of the Confederate States, that he would be happy to
receive a diplomatic agent of that government, and would consult
the Senate upon what that agent had to propose.
3. The date of Mr. Crawford’s departure from Montgomery, “on or
about February 27th,” the date of his arrival in Washington, “two or
three days before the expiration of Mr. Buchanan’s term of office,”
and the fact that Mr. Buchanan declined to receive him or to send
any message to the Senate touching the subject of his mission,
militate strongly against the correctness of the assertion that he
went there in consequence of an intimation from Mr. Buchanan that
such an agent would be received. If such an intimation had been
given, the President could have had no excuse for refusing to hold
any communication with the agent, even if he did not arrive until the
last two or three days of the administration.
4. Mr. Crawford, in a manuscript account which he furnished to Mr.
Davis of his “recollections of events connected with” his mission,
represents Mr. Buchanan as “panic-stricken;” in “a state of most
thorough alarm, not only for his home at Wheatland, but for his
personal safety;” that he was “afraid of a public visit” from the
commissioner whose appointment he had himself suggested, and
whom he had promised to receive.[159] Mr. Crawford is not alone in
imputing “panic” to Mr. Buchanan. It was a common mode, both
with Mr. Buchanan’s Northern and his Southern enemies, to
represent him as bewildered, confused, timorous, not only during
the last days, but during the last months of his administration. This
was their way of accounting for conduct which, for very opposite
reasons, they disliked. It has been my duty, in investigating day by
day every act of his official and private life during this period, to
penetrate into his closet, if I may so express myself, and to form an
opinion respecting the effect upon him of the great and critical
events with which he had to deal. The materials for such an opinion,
when one has access to the written evidence of what such a
statesman was doing from day to day and from hour to hour, are
almost as ample as if one had all the while been at his side and sate
at his board. It seems to me the veriest folly, to speak of a man as
panic-stricken or bewildered, who was daily and hourly answering
with his own hand the most important public despatches, and the
most familiar private letters, in the manner appropriate to each;
recording with his own pen important conversations; holding cabinet
councils; giving directions and transacting with punctuality and order
the multifarious business of a great office; attending to his own
private concerns, and grasping firmly the helm of state amid waves
that rose higher and were more dangerous than any through which
the good ship had ever floated; entertaining friends, enjoying the
delights of social intercourse, writing at one time the gravest and
most important messages to Congress, and then congratulating a
young lady friend on her approaching marriage, in as graceful and
charming a little note as a woman ever received. I cannot give to the
reader an adequate idea of what I have gone through, in the study
of these last four months of Mr. Buchanan’s official life. I can only
say that on me it has produced the impression of great versatility of
powers, immense industry, complete self-command, unshaken
firmness, and undeviating consistency. That a man of nearly seventy
years should have encountered, as he did, what he had to
encounter, with so little sign of fear, is the best proof of an
undaunted temper and a serene self-possession. The gossip of
Pennsylvania Avenue, and the tattle of secession circles, supposed
him to be panic-stricken; while he sate in the White House the most
remarkable instance, in those tumultuous times, of the mens aequa
in arduis.[160]
It seems to be quite evident from Mr. Tyler’s note of February
24th, to the President, that so far as any suggestion of a commission
to be sent by Mr. Davis to Washington proceeded from that city, it
proceeded from Mr. Tyler himself, and those gentlemen of his own
State who, acting with him, were endeavoring to ward off any attack
upon Fort Sumter. Mr. Davis became President of the Confederate
States on the 18th of February. But before that date, Mr. Tyler was
actively engaged in efforts to prevent an armed collision at
Charleston; and as it was well known that Mr. Davis would be the
President of the new confederacy whose delegates had assembled at
Montgomery, Mr. Tyler and the other Virginians looked to him to
prevent any outbreak in South Carolina. But I know of nothing that
can connect Mr. Buchanan with the suggestion of a commission,
beyond Mr. Davis’s statement, which is wholly unsupported by proof.
The fair inference from all that occurred is, that the commission was
sent to Washington to take the chances of being received by the
out-going or the incoming administration, as circumstances might
admit. As the first commissioner did not leave Montgomery until the
27th of February, it could not have been expected that Mr. Buchanan
would take the responsibility of binding his successor by negotiating
with a diplomatic agent of the Confederate States during the last
three days of his administration; nor is it probable that Mr. Davis,
whose last words in the Senate of the United States arraigned Mr.
Buchanan severely for his course towards South Carolina, had, as
President of the Confederate States, received from Mr. Buchanan an
intimation that was equivalent to an invitation from one potentate to
another to send a commission for the adjustment of all differences
between their two governments.
“He is advised to send a commission,” said Mr. Tyler to Mr.
Buchanan. Advised by whom? “By me, Mr. Tyler, and those Virginians
who are acting with me,” is plainly to be read between the lines of
Mr. Tyler’s letter of February 24th to the President. No one can doubt
that Mr. Buchanan’s account of his administration, published in 1866,
was written with perfect candor. If he had ever sent to Mr. Davis the
intimation which that gentleman says he received from him through
a third person, inviting commissioners from the Confederate
Government, he would have stated the fact, together with his
reasons for it. He never shrank from assigning reasons for any thing
that he ever did. Yet not only does he make no allusion to the
Montgomery commissioners, but any one who reads his fair and
considerate comments on the peace policy pursued by Mr. Lincoln
down to the attack on Fort Sumter, ought to be convinced that there
was no need for the presence of Confederate commissioners in
Washington, coming there on the suggestion of Mr. Buchanan, to
negotiate matters that would have to be referred to the Senate,
although it is highly probable that Mr. Tyler may have desired that a
commissioner be sent to arrange amicably for an agreement by the
Confederates not to attack Fort Sumter.
CHAPTER XXV.
1861—February and March.

TROOPS AT THE CAPITAL—INAUGURATION OF PRESIDENT


LINCOLN—IMPORTANT AND ALARMING DESPATCHES FROM
MAJOR ANDERSON—MR. HOLT’S COMMUNICATION TO
PRESIDENT LINCOLN—ATTITUDE IN WHICH MR. BUCHANAN
LEFT THE GOVERNMENT TO HIS SUCCESSOR—HIS DEPARTURE
FOR WHEATLAND.

As the administration was drawing to its end, great uneasiness


was felt by many persons in Washington for the safety of the capital
and the Government. Rumors of a conspiracy to seize the city and to
prevent the inauguration of the President-elect filled the air. Among
those who were affected by these rumors was the Secretary of
State, Judge Black. With characteristic energy, on the 22d of
January, being prevented by illness from attending the cabinet
meeting of that day, he addressed to the President a long and
earnest private letter, setting forth the grounds of his belief that the
existence of such a conspiracy was highly probable, and that at all
events, even if it were doubtful, the Government ought to be
prepared for the worst. The President, although at first he did not
share these apprehensions, was not the less vigilant in the discharge
of his executive duties, or the less disposed to give due weight to
Judge Black’s impressive arguments. He would have had everything
needful done in a manner not to excite public observation, if the
matter had not been broached in Congress. His message of the 8th
of January had been referred on the 10th, in the House of
Representatives, to a select committee of five members, consisting
of Messrs. Howard, of Michigan, Branch, of North Carolina, Dawes,
of Massachusetts, John Cochrane, of New York, and Hickman, of
Pennsylvania. On the 25th this committee were instructed, by a
resolution offered by Mr. Grow, of Pennsylvania, “to inquire whether
any secret organization hostile to the Government of the United
States exists in the District of Columbia; and if so, whether any
official or employé of the city of Washington, or any employées or
officers of the Federal Government, in the Executive or Judicial
Departments, are members of it.” Before this committee had
reported, steps had been taken by the Executive to assemble quietly
at Washington a small body of the regular troops. This at once
aroused the jealousy of certain members from the border States. On
the 11th of February, a resolution, offered by Mr. Burnett, of
Kentucky, was adopted in the House, calling upon the President to
furnish to the House, if not incompatible with the public service, “the
reasons that have induced him to assemble a large number of troops
in this city, why they are kept here, and whether he has any
information of a conspiracy on the part of any portion of the citizens
of the country to seize the capital and prevent the inauguration of
the President-elect.”
On the 14th of February the select committee reported all the
testimony they had taken, and expressed their unanimous opinion
that the evidence produced before them did not prove the existence
of a secret organization at Washington, or elsewhere, for purposes
hostile to the Government.
Thereupon Mr. Branch, of North Carolina, introduced another
resolution, condemning the quartering of troops at the capital.
In the meantime, the Secretary of War, Mr. Holt, on the 18th of
February, made a full report to the President, in response to Mr.
Burnett’s resolution of the 11th, setting forth the reasons for the
assembling of the troops, and officially declaring that their presence
“is the result of the conclusion arrived at by yourself and cabinet, on
the proposition submitted to you by this department.” On the 20th,
Mr. Holt addressed to the President the following private note:
[MR. HOLT TO THE PRESIDENT.]
War Department, Feb. 20, 1861.
Dear Sir:—
I inclose a copy of the resolution referred to in the paper which I
had the honor to address to you on yesterday, and trust I shall be
pardoned for saying that I shall be very unhappy, if this defence—
truthful and tempered as it is—is not permitted to reach the country.
The act of assembling troops at the capital, and providing for the
inauguration of your successor under the shelter of their guns, is
one of the gravest and most responsible of your administration. It
constitutes, indeed, an epoch in the history of our institutions, and
as the circumstances surrounding you fully justify the measure, they
should be frankly and fearlessly set forth to the world. For this step
your administration has been, and still continues to be, mercilessly
denounced, and of this denunciation, as you are aware, a large part
has fallen to my share. I have been defamed in my own State, and
in the towns of my nearest relatives and friends, and I confess that I
have not yet attained to the Christian philosophy of bearing such
things as an ox led to the slaughter, without opening my mouth.
Congress is now engaged in spreading broadcast over the country,
through the efforts of your enemies and mine, a report intended to
show that the safety of the capital has never been menaced, and of
course that all your preparations here have been prompted by
cowardice, or the spirit of despotism. Now is the time to meet this
calumny. A few weeks hence the memory of the measure assailed
will be swallowed up by the heady current of events, and nothing
will remain but the wounds to the reputation and sensibilities of your
friends who gave to that measure their honest and zealous support.
I do not ask you to adopt my report as your own, but to submit it
simply as the views entertained by the War Department, and for
which its head should alone be held responsible.
The helplessness of my position for all purposes of self-defence,
without your kind cooperation, must be my apology for the solicitude
expressed.
Very sincerely your friend,
J. Holt.

The President did not at once concur in Mr. Holt’s views of the
necessity for making public the reasons which had governed the
Executive in ordering the troops to Washington. In a memorandum
which now lies before me in his handwriting, he says:

After the Committee of Five had reported all the testimony which
could be collected in the case, with their opinion upon the result of
it, the President did not deem it necessary to answer Mr. Burnett’s
resolution. Understanding, however, that he and other members
considered it disrespectful to the Union, not to return an answer, he
[on the 2d of March] sent a message to the House, in response to
the resolution.

This was in ample season to inform everybody that the troops


were in Washington to secure a peaceful inauguration of his
successor against all possibility of danger; the imputations cast upon
his administration in the meantime were of less immediate
consequence. The table given below shows the number of troops
present in the city on the 27th of February, and until after the 4th of
March.[161]
The following is the material part of the special message of March
2, 1861:

These troops were ordered here to act as a posse comitatus in


strict subordination to the civil authority, for the purpose of
preserving peace and order in the City of Washington, should this be
necessary before or at the period of the inauguration of the
President-elect. I was convinced that I ought to act. The safety of
the immense amount of public property in this city, and that of the
archives of the Government, in which all the States, and especially
the new States in which the public lands are situated, have a deep
interest; the peace and order of the city itself and the security of the
inauguration of the President-elect, were objects of such vast

You might also like