0% нашли этот документ полезным (0 голосов)
7 просмотров

Interactive Object-Oriented Programming in Java: Learn and Test Your Programming Skills, 2nd Edition Vaskaran Sarcar pdf download

Книга 'Interactive Object-Oriented Programming in Java' второго издания авторства Васкарана Саркара предназначена для изучения и тестирования навыков программирования на Java. Она охватывает основные концепции объектно-ориентированного программирования, такие как классы, объекты, наследование и полиморфизм, а также включает практические демонстрации и сессии вопросов и ответов. Издание содержит актуальную информацию и примеры, полезные как для начинающих, так и для опытных программистов.

Загружено:

sicosyoeyoe
Авторское право
© © All Rights Reserved
Доступные форматы
Скачать в формате PDF, TXT или читать онлайн в Scribd
0% нашли этот документ полезным (0 голосов)
7 просмотров

Interactive Object-Oriented Programming in Java: Learn and Test Your Programming Skills, 2nd Edition Vaskaran Sarcar pdf download

Книга 'Interactive Object-Oriented Programming in Java' второго издания авторства Васкарана Саркара предназначена для изучения и тестирования навыков программирования на Java. Она охватывает основные концепции объектно-ориентированного программирования, такие как классы, объекты, наследование и полиморфизм, а также включает практические демонстрации и сессии вопросов и ответов. Издание содержит актуальную информацию и примеры, полезные как для начинающих, так и для опытных программистов.

Загружено:

sicosyoeyoe
Авторское право
© © All Rights Reserved
Доступные форматы
Скачать в формате PDF, TXT или читать онлайн в Scribd
Вы находитесь на странице: 1/ 49

Interactive Object-Oriented Programming in Java:

Learn and Test Your Programming Skills, 2nd


Edition Vaskaran Sarcar download

https://ebookmeta.com/product/interactive-object-oriented-
programming-in-java-learn-and-test-your-programming-skills-2nd-
edition-vaskaran-sarcar/

Download more ebook from https://ebookmeta.com


Interactive
Object-Oriented
Programming
in Java
Learn and Test Your Programming Skills

Second Edition

Vaskaran Sarcar
Foreword by Avirup Mullick

www.allitebooks.com
Interactive
Object-­Oriented
Programming in Java
Learn and Test Your
Programming Skills
Second Edition

Vaskaran Sarcar
Foreword by Avirup Mullick

www.allitebooks.com
Interactive Object-Oriented Programming in Java
Vaskaran Sarcar
Bangalore, Karnataka, India

ISBN-13 (pbk): 978-1-4842-5403-5 ISBN-13 (electronic): 978-1-4842-5404-2


https://doi.org/10.1007/978-1-4842-5404-2

Copyright © 2020 by Vaskaran Sarcar


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

www.allitebooks.com
Dear Reader,
You motivate me with your nice and loving comments,
you hurt me with your extremely critical comments, but in the
end you help me to become a better person and a better author.
So, this book is dedicated to you.

www.allitebooks.com
Table of Contents
About the Author����������������������������������������������������������������������������������������������������xix
About the Technical Reviewer��������������������������������������������������������������������������������xxi
Acknowledgments������������������������������������������������������������������������������������������������xxiii
Preface������������������������������������������������������������������������������������������������������������������xxv
Who Is This Book For?������������������������������������������������������������������������������������������xxix
Guidelines for Using This Book�����������������������������������������������������������������������������xxxi
Conventions Used in This Book��������������������������������������������������������������������������xxxiii
Foreword�������������������������������������������������������������������������������������������������������������xxxv

Part I: Fundamentals of Object-­Oriented Programming.................................. 1


Chapter 1: Object-Oriented Programming Concepts������������������������������������������������ 3
Class and Objects������������������������������������������������������������������������������������������������������������������������� 5
Encapsulation������������������������������������������������������������������������������������������������������������������������������� 6
Abstraction������������������������������������������������������������������������������������������������������������������������������������ 6
Inheritance������������������������������������������������������������������������������������������������������������������������������������ 7
Polymorphism������������������������������������������������������������������������������������������������������������������������������� 7
Q&A Session���������������������������������������������������������������������������������������������������������������������������������� 8
Summary�������������������������������������������������������������������������������������������������������������������������������������� 9

Chapter 2: The Building Blocks: Class and Objects������������������������������������������������ 11


Class������������������������������������������������������������������������������������������������������������������������������������������� 11
Object������������������������������������������������������������������������������������������������������������������������������������������ 11
Constructor��������������������������������������������������������������������������������������������������������������������������������� 14
Demonstration 1�������������������������������������������������������������������������������������������������������������������� 17
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 19

www.allitebooks.com
Table of Contents

Demonstration 2�������������������������������������������������������������������������������������������������������������������� 19
Analysis��������������������������������������������������������������������������������������������������������������������������������� 20
Demonstration 3�������������������������������������������������������������������������������������������������������������������� 26
Demonstration 4�������������������������������������������������������������������������������������������������������������������� 29
Demonstration 5�������������������������������������������������������������������������������������������������������������������� 31
Passing Variable-Length Arguments to Methods������������������������������������������������������������������������ 32
Demonstration 6�������������������������������������������������������������������������������������������������������������������� 32
Analysis��������������������������������������������������������������������������������������������������������������������������������� 33
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 33
Summary������������������������������������������������������������������������������������������������������������������������������������ 35

Chapter 3: Classes and Objects in Depth���������������������������������������������������������������� 37


Static Variables and Methods����������������������������������������������������������������������������������������������������� 37
Demonstration 1�������������������������������������������������������������������������������������������������������������������� 38
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 39
Access Control���������������������������������������������������������������������������������������������������������������������������� 39
Demonstration 2�������������������������������������������������������������������������������������������������������������������� 40
Getter-Setter Methods���������������������������������������������������������������������������������������������������������������� 42
Demonstration 3�������������������������������������������������������������������������������������������������������������������� 42
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 43
Initialization Block����������������������������������������������������������������������������������������������������������������������� 43
Demonstration 4�������������������������������������������������������������������������������������������������������������������� 44
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 45
Nested Class������������������������������������������������������������������������������������������������������������������������������� 47
Demonstration 5�������������������������������������������������������������������������������������������������������������������� 47
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 49
Copying an Object����������������������������������������������������������������������������������������������������������������������� 49
Using Copy Constructors������������������������������������������������������������������������������������������������������� 49
Demonstration 6�������������������������������������������������������������������������������������������������������������������� 50
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 51
Wrapper Class����������������������������������������������������������������������������������������������������������������������������� 51
Demonstration 7�������������������������������������������������������������������������������������������������������������������� 52

vi
Table of Contents

Garbage Collection���������������������������������������������������������������������������������������������������������������������� 54
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 55
Demonstration 8�������������������������������������������������������������������������������������������������������������������� 57
Finalization���������������������������������������������������������������������������������������������������������������������������������� 60
Demonstration 9�������������������������������������������������������������������������������������������������������������������� 61
Summary������������������������������������������������������������������������������������������������������������������������������������ 63

Chapter 4: The Concept of Inheritance������������������������������������������������������������������� 65


Types of Inheritance�������������������������������������������������������������������������������������������������������������������� 65
Single Inheritance����������������������������������������������������������������������������������������������������������������� 65
Hierarchical Inheritance�������������������������������������������������������������������������������������������������������� 66
Multi-level Inheritance���������������������������������������������������������������������������������������������������������� 67
Multiple Inheritance��������������������������������������������������������������������������������������������������������������� 68
Demonstration 1�������������������������������������������������������������������������������������������������������������������� 69
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 70
Demonstration 2�������������������������������������������������������������������������������������������������������������������� 70
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 72
Demonstration 3�������������������������������������������������������������������������������������������������������������������� 72
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 74
Demonstration 4�������������������������������������������������������������������������������������������������������������������� 75
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 76
A Special Keyword: super����������������������������������������������������������������������������������������������������������� 76
Demonstration 5�������������������������������������������������������������������������������������������������������������������� 77
Demonstration 6�������������������������������������������������������������������������������������������������������������������� 81
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 83
Demonstration 7�������������������������������������������������������������������������������������������������������������������� 84
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 85
Demonstration 8�������������������������������������������������������������������������������������������������������������������� 86
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 87
Demonstration 9�������������������������������������������������������������������������������������������������������������������� 88
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 89
Summary������������������������������������������������������������������������������������������������������������������������������������ 90

vii
Table of Contents

Chapter 5: Get Familiar with Polymorphism����������������������������������������������������������� 91


Method Overloading�������������������������������������������������������������������������������������������������������������������� 91
Demonstration 1�������������������������������������������������������������������������������������������������������������������� 91
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 93
Demonstration 2�������������������������������������������������������������������������������������������������������������������� 95
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 96
Demonstration 3�������������������������������������������������������������������������������������������������������������������� 96
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 97
Demonstration 4�������������������������������������������������������������������������������������������������������������������� 97
Q&A Session�������������������������������������������������������������������������������������������������������������������������� 98
Demonstration 5�������������������������������������������������������������������������������������������������������������������� 99
Method Overriding�������������������������������������������������������������������������������������������������������������������� 101
Demonstration 6������������������������������������������������������������������������������������������������������������������ 102
Q&A Session������������������������������������������������������������������������������������������������������������������������ 104
Demonstration 7������������������������������������������������������������������������������������������������������������������ 106
Runtime Polymorphism������������������������������������������������������������������������������������������������������������� 108
Demonstration 8������������������������������������������������������������������������������������������������������������������ 109
Q&A Session������������������������������������������������������������������������������������������������������������������������ 111
Demonstration 9������������������������������������������������������������������������������������������������������������������ 111
Q&A Session������������������������������������������������������������������������������������������������������������������������ 114
Demonstration 10���������������������������������������������������������������������������������������������������������������� 115
Using the final Keyword������������������������������������������������������������������������������������������������������������ 117
Blank final Variables������������������������������������������������������������������������������������������������������������ 119
Q&A Session������������������������������������������������������������������������������������������������������������������������ 120
Demonstration 11���������������������������������������������������������������������������������������������������������������� 120
Q&A Session������������������������������������������������������������������������������������������������������������������������ 122
Demonstration 12���������������������������������������������������������������������������������������������������������������� 124
Q&A Session������������������������������������������������������������������������������������������������������������������������ 126
Demonstration 13���������������������������������������������������������������������������������������������������������������� 127
Q&A Session������������������������������������������������������������������������������������������������������������������������ 128
Demonstration 14���������������������������������������������������������������������������������������������������������������� 129

viii
Table of Contents

Covariant Return Type��������������������������������������������������������������������������������������������������������������� 130


Demonstration 15���������������������������������������������������������������������������������������������������������������� 130
Demonstration 16���������������������������������������������������������������������������������������������������������������� 133
Q&A Session������������������������������������������������������������������������������������������������������������������������ 134
Use of Private Constructors������������������������������������������������������������������������������������������������������ 135
Q&A Session������������������������������������������������������������������������������������������������������������������������ 135
Demonstration 17���������������������������������������������������������������������������������������������������������������� 136
Q&A Session������������������������������������������������������������������������������������������������������������������������ 138
Summary���������������������������������������������������������������������������������������������������������������������������������� 139

Chapter 6: Abstract Classes and Interfaces: The True Art in OOP������������������������ 141
Abstract Classes����������������������������������������������������������������������������������������������������������������������� 141
Demonstration 1������������������������������������������������������������������������������������������������������������������ 142
Demonstration 2������������������������������������������������������������������������������������������������������������������ 143
Q&A Session������������������������������������������������������������������������������������������������������������������������ 146
Interfaces���������������������������������������������������������������������������������������������������������������������������������� 151
Demonstration 3������������������������������������������������������������������������������������������������������������������ 153
Q&A Session������������������������������������������������������������������������������������������������������������������������ 154
Demonstration 4������������������������������������������������������������������������������������������������������������������ 155
Q&A Session������������������������������������������������������������������������������������������������������������������������ 156
Demonstration 5������������������������������������������������������������������������������������������������������������������ 157
Q&A Session������������������������������������������������������������������������������������������������������������������������ 158
Demonstration 6������������������������������������������������������������������������������������������������������������������ 158
Q&A Session������������������������������������������������������������������������������������������������������������������������ 160
Demonstration 7������������������������������������������������������������������������������������������������������������������ 160
Q&A Session������������������������������������������������������������������������������������������������������������������������ 163
Marker Interface����������������������������������������������������������������������������������������������������������������������� 163
A Quick Tour with Annotations�������������������������������������������������������������������������������������������������� 164
Demonstration 8������������������������������������������������������������������������������������������������������������������ 165
Demonstration 9������������������������������������������������������������������������������������������������������������������ 169
Javadoc Snapshots������������������������������������������������������������������������������������������������������������� 170
Q&A Session������������������������������������������������������������������������������������������������������������������������ 171

ix
Table of Contents

Default Methods in Interfaces��������������������������������������������������������������������������������������������������� 173


Demonstration 10���������������������������������������������������������������������������������������������������������������� 173
Q&A Session������������������������������������������������������������������������������������������������������������������������ 175
Demonstration 11���������������������������������������������������������������������������������������������������������������� 176
Q&A Session������������������������������������������������������������������������������������������������������������������������ 178
Demonstration 12���������������������������������������������������������������������������������������������������������������� 179
Summary���������������������������������������������������������������������������������������������������������������������������������� 180

Chapter 7: Packages��������������������������������������������������������������������������������������������� 183


Creating a Package������������������������������������������������������������������������������������������������������������������� 185
Demonstration 1������������������������������������������������������������������������������������������������������������������ 188
Key Notes About Packages in Java�������������������������������������������������������������������������������������� 192
Q&A Session������������������������������������������������������������������������������������������������������������������������ 193
Demonstration 2������������������������������������������������������������������������������������������������������������������ 195
Q&A Session������������������������������������������������������������������������������������������������������������������������ 196
Troubleshooting Common Errors in Command-line Environment��������������������������������������������� 197
Summary���������������������������������������������������������������������������������������������������������������������������������� 200

Chapter 8: Understanding Class Variables and Class Methods���������������������������� 201


Class Variables and Class Methods������������������������������������������������������������������������������������������� 202
Demonstration 1������������������������������������������������������������������������������������������������������������������ 202
Working with Nested Classes��������������������������������������������������������������������������������������������������� 203
Demonstration 2������������������������������������������������������������������������������������������������������������������ 203
Q&A Session������������������������������������������������������������������������������������������������������������������������ 207
Initialization Blocks Versus Constructors���������������������������������������������������������������������������������� 208
Demonstration 3������������������������������������������������������������������������������������������������������������������ 210
Method Hiding Versus Method Overriding��������������������������������������������������������������������������������� 214
Demonstration 4������������������������������������������������������������������������������������������������������������������ 215
Q&A Session������������������������������������������������������������������������������������������������������������������������ 217
Method Overloading������������������������������������������������������������������������������������������������������������������ 217
Demonstration 5������������������������������������������������������������������������������������������������������������������ 217
Q&A Session������������������������������������������������������������������������������������������������������������������������ 220

x
Table of Contents

Static Methods in Interfaces����������������������������������������������������������������������������������������������������� 220


Demonstration 6������������������������������������������������������������������������������������������������������������������ 221
Summary���������������������������������������������������������������������������������������������������������������������������������� 223

Chapter 9: Quick Recap of OOP Principles������������������������������������������������������������ 225


Q&A Session������������������������������������������������������������������������������������������������������������������������������ 226
Revisiting the Diamond Problem����������������������������������������������������������������������������������������������� 229
Demonstration 1������������������������������������������������������������������������������������������������������������������ 230
Q&A Session������������������������������������������������������������������������������������������������������������������������������ 232
Summary���������������������������������������������������������������������������������������������������������������������������������� 235

Part II: Get Familiar with Advanced Programming...................................... 237


Chapter 10: Managing Exceptions������������������������������������������������������������������������ 239
Types of Mistakes��������������������������������������������������������������������������������������������������������������������� 239
Definition of Exception�������������������������������������������������������������������������������������������������������������� 241
Demonstration 1������������������������������������������������������������������������������������������������������������������ 241
Key Points of the Exception-handling Mechanism�������������������������������������������������������������� 242
Demonstration 2������������������������������������������������������������������������������������������������������������������ 245
Q&A Session������������������������������������������������������������������������������������������������������������������������ 247
Demonstration 3������������������������������������������������������������������������������������������������������������������ 247
Multiple catch Clauses�������������������������������������������������������������������������������������������������������������� 250
Q&A Session������������������������������������������������������������������������������������������������������������������������ 253
Demonstration 4������������������������������������������������������������������������������������������������������������������ 254
Q&A Session������������������������������������������������������������������������������������������������������������������������ 255
Throwing an Exception������������������������������������������������������������������������������������������������������������� 255
Demonstration 5������������������������������������������������������������������������������������������������������������������ 256
Rethrowing an Exception���������������������������������������������������������������������������������������������������������� 257
Demonstration 6������������������������������������������������������������������������������������������������������������������ 257
Use of throws Keyword������������������������������������������������������������������������������������������������������������� 260
Demonstration 7������������������������������������������������������������������������������������������������������������������ 261
Demonstration 8������������������������������������������������������������������������������������������������������������������ 263

xi
Table of Contents

Checked Versus Unchecked Exceptions������������������������������������������������������������������������������������ 265


Q&A Session������������������������������������������������������������������������������������������������������������������������ 266
Discussion on Chained Exceptions������������������������������������������������������������������������������������������� 266
Demonstration 9������������������������������������������������������������������������������������������������������������������ 267
Creating a Custom Exception���������������������������������������������������������������������������������������������������� 272
Demonstration 10���������������������������������������������������������������������������������������������������������������� 273
Q&A Session������������������������������������������������������������������������������������������������������������������������ 276
Demonstration 11���������������������������������������������������������������������������������������������������������������� 276
Q&A Session������������������������������������������������������������������������������������������������������������������������ 277
Demonstration 12���������������������������������������������������������������������������������������������������������������� 278
Summary���������������������������������������������������������������������������������������������������������������������������������� 280

Chapter 11: Thread Programming������������������������������������������������������������������������ 281


Creating Threads����������������������������������������������������������������������������������������������������������������������� 283
Extending the Thread Class������������������������������������������������������������������������������������������������������� 284
Demonstration 1������������������������������������������������������������������������������������������������������������������ 285
Implementing the Runnable Interface��������������������������������������������������������������������������������������� 288
Demonstration 2������������������������������������������������������������������������������������������������������������������ 288
Q&A Session������������������������������������������������������������������������������������������������������������������������ 291
Demonstration 3������������������������������������������������������������������������������������������������������������������ 292
Case Study with Different Thread Class Methods��������������������������������������������������������������������� 300
Demonstration 4������������������������������������������������������������������������������������������������������������������ 301
Q&A Session������������������������������������������������������������������������������������������������������������������������ 303
Synchronization������������������������������������������������������������������������������������������������������������������������ 305
Use of Synchronized Methods��������������������������������������������������������������������������������������������� 306
Demonstration 5������������������������������������������������������������������������������������������������������������������ 307
Use of Synchronized Block�������������������������������������������������������������������������������������������������� 309
Demonstration 6������������������������������������������������������������������������������������������������������������������ 309
Deadlock����������������������������������������������������������������������������������������������������������������������������������� 311
Types of Deadlock��������������������������������������������������������������������������������������������������������������� 311
Demonstration 7������������������������������������������������������������������������������������������������������������������ 312
Detecting Deadlocks in the System������������������������������������������������������������������������������������� 314

xii
Table of Contents

Interthread Communication������������������������������������������������������������������������������������������������������ 317


Demonstration 8������������������������������������������������������������������������������������������������������������������ 319
Lifecycle of a Thread����������������������������������������������������������������������������������������������������������������� 323
Q&A Session������������������������������������������������������������������������������������������������������������������������ 325
Summary���������������������������������������������������������������������������������������������������������������������������������� 327

Chapter 12: Generic Programming����������������������������������������������������������������������� 329


Compare Generic Programs with Non-Generic Programs��������������������������������������������������������� 329
Demonstration 1������������������������������������������������������������������������������������������������������������������ 329
Demonstration 2������������������������������������������������������������������������������������������������������������������ 331
Demonstration 3������������������������������������������������������������������������������������������������������������������ 335
Demonstration 4������������������������������������������������������������������������������������������������������������������ 337
Wildcard Types in Generic Programming���������������������������������������������������������������������������������� 340
Upper-bound Wildcard��������������������������������������������������������������������������������������������������������� 340
Demonstration 5������������������������������������������������������������������������������������������������������������������ 342
Lower-bound Wildcard��������������������������������������������������������������������������������������������������������� 346
Demonstration 6������������������������������������������������������������������������������������������������������������������ 346
Unbounded Wildcard����������������������������������������������������������������������������������������������������������� 349
Q&A Session������������������������������������������������������������������������������������������������������������������������ 350
Demonstration 6A���������������������������������������������������������������������������������������������������������������� 354
Bounded Type Parameter���������������������������������������������������������������������������������������������������������� 355
Demonstration 7������������������������������������������������������������������������������������������������������������������ 357
Demonstration 8������������������������������������������������������������������������������������������������������������������ 360
Q&A Session������������������������������������������������������������������������������������������������������������������������ 361
Erasures������������������������������������������������������������������������������������������������������������������������������������ 361
Demonstration 9������������������������������������������������������������������������������������������������������������������ 362
Raw Types��������������������������������������������������������������������������������������������������������������������������������� 366
Demonstration 10���������������������������������������������������������������������������������������������������������������� 367
Q&A Session������������������������������������������������������������������������������������������������������������������������ 368

xiii
Table of Contents

Type Inference Using Diamond Operator����������������������������������������������������������������������������������� 369


Applying Inheritance����������������������������������������������������������������������������������������������������������������� 370
Demonstration 11���������������������������������������������������������������������������������������������������������������� 370
Bridge Method��������������������������������������������������������������������������������������������������������������������� 372
Demonstration 12���������������������������������������������������������������������������������������������������������������� 373
Important Restrictions in Generic Programming����������������������������������������������������������������������� 375
Don’t Instantiate Generic Types with Primitive Types���������������������������������������������������������� 376
Your Generic Class Cannot Subclass Directly or Indirectly from Throwable������������������������ 376
You Cannot Overload a Method Where the Formal Parameter Types of Each
Overload Are Erased to the Same Raw Type������������������������������������������������������������������������ 376
Static Field Type Parameter Is Not Allowed in Your Generic Class�������������������������������������� 377
You Cannot Instantiate the Type Parameters In Your Generic Class������������������������������������ 377
One Final Suggestion����������������������������������������������������������������������������������������������������������� 378
Summary���������������������������������������������������������������������������������������������������������������������������������� 378

Chapter 13: Database Programming�������������������������������������������������������������������� 381


Database and DBMS����������������������������������������������������������������������������������������������������������������� 382
Types of DBMS�������������������������������������������������������������������������������������������������������������������� 382
RDBMS�������������������������������������������������������������������������������������������������������������������������������� 383
SQL�������������������������������������������������������������������������������������������������������������������������������������� 384
Connecting to a Database��������������������������������������������������������������������������������������������������������� 385
Q&A Session������������������������������������������������������������������������������������������������������������������������ 387
Talking to a Database in a Java Application������������������������������������������������������������������������������ 388
Important Terms������������������������������������������������������������������������������������������������������������������������ 390
Creating a Database and Inserting Records������������������������������������������������������������������������������ 392
MySQL Command Prompt View������������������������������������������������������������������������������������������� 395
Demonstration 1������������������������������������������������������������������������������������������������������������������ 397
Demonstration 2������������������������������������������������������������������������������������������������������������������ 399
Demonstration 3������������������������������������������������������������������������������������������������������������������ 403
Q&A Session������������������������������������������������������������������������������������������������������������������������ 408
Demonstration 4������������������������������������������������������������������������������������������������������������������ 410

xiv
Table of Contents

Q&A Session������������������������������������������������������������������������������������������������������������������������ 417


Demonstration 5������������������������������������������������������������������������������������������������������������������ 418
Summary���������������������������������������������������������������������������������������������������������������������������������� 421

Chapter 14: Important Features in Java’s Enhancement Path������������������������������ 423


Try-with-resource from Java 7������������������������������������������������������������������������������������������������� 423
Demonstration 1������������������������������������������������������������������������������������������������������������������ 424
Q&A Session������������������������������������������������������������������������������������������������������������������������ 425
Implementing Functional Interface Methods Using Lambda Expressions from Java 8������������ 425
Demonstration 2������������������������������������������������������������������������������������������������������������������ 426
Q&A Session������������������������������������������������������������������������������������������������������������������������ 427
Private Interface Method from Java 9��������������������������������������������������������������������������������������� 428
Demonstration 3������������������������������������������������������������������������������������������������������������������ 428
Q&A Session������������������������������������������������������������������������������������������������������������������������ 430
Local Variable Type Inference from Java 10������������������������������������������������������������������������������ 432
Demonstration 4������������������������������������������������������������������������������������������������������������������ 432
Restrictions������������������������������������������������������������������������������������������������������������������������� 433
New String Methods from Java 11������������������������������������������������������������������������������������������� 434
Demonstration 5������������������������������������������������������������������������������������������������������������������ 434
Q&A Session������������������������������������������������������������������������������������������������������������������������ 435
New switch Expression in Java 12/13�������������������������������������������������������������������������������������� 437
Demonstration 6������������������������������������������������������������������������������������������������������������������ 437
Q&A Session������������������������������������������������������������������������������������������������������������������������ 439
Summary���������������������������������������������������������������������������������������������������������������������������������� 439

Part III: Explore Real-World Scenarios........................................................ 441


Chapter 15: Introduction to Design Patterns�������������������������������������������������������� 443
Key Points��������������������������������������������������������������������������������������������������������������������������������� 444
Creational Patterns�������������������������������������������������������������������������������������������������������������� 445
Structural Patterns�������������������������������������������������������������������������������������������������������������� 446

xv
Another Random Scribd Document
with Unrelated Content
America, as to deny that weaknesses and dangers, and evils both
secret and public, do there abound. Those who base their judgments
less on knowledge of democratic forces than on obvious and
somewhat sentimental social prejudices are apt to look for the
dangers in the wrong direction. A German naturally thinks of mob-
rule, harangues of the demagogue, and every form of lawlessness
and violence. But true democracy does not allow of such things. A
people that allows itself to turn into a mob and to be guided by
irresponsible leaders, is not capable of directing itself. Self-direction
demands the education of the nation. And nowhere else in the world
is the mere demagogue so powerless, and nowhere does the
populace observe more exemplary order and self-discipline.
The essential weakness of such a democracy is rather the
importance it assigns to the average man with his petty opinions,
which are sometimes right and sometimes wrong, his total lack of
comprehension for all that is great and exceptional, his self-satisfied
dilettanteism and his complacency before the accredited and trite in
thought. This is far less true of a republic like the French, with its
genius for scepticism, a republic nourished in æsthetic traditions and
founded on the ruins of an empire. The intellectual conditions are
there quite different. But in an ethical democracy, where self-
direction is a serious issue, domination by the average intelligence is
inevitable; and those who are truly great are the ones who find no
scope for their powers. Those who appear great are merely men
who are exploiting to the utmost the tendencies of the day. There
are no great distinctions or premiums for truly high achievements
which do not immediately concern the average man, and therefore
the best energies of the nation are not spurred on to their keenest
activity. All ambition is directed necessarily toward such
achievements as the common man can understand and compete for
—athletic virtuosity and wealth. Therefore the spirit of sport and of
money-getting concerns the people more nearly than art or science,
and even in politics the domination of the majority easily crowds
from the arena those whose qualifications do not appeal to its
mediocre taste. And by as much as mature and capable minds
withdraw from political life, by so much are the well-intentioned
masses more easily led astray by sharp and self-interested politicians
and politics made to cater to mean instincts. In short, the danger is
not from any wild lawlessness, but from a crass philistinism. The
seditious demagogue who appeals to passion is less dangerous than
the sly political wire-puller who exploits the indolence and
indifference of the people; and evil intent is less to be feared than
dilettanteism and the intellectual limitations of the general public.
But, on the other hand, it is also certain that when it comes to a
critical comparison between the weaknesses and theoretical dangers
of democracy and aristocracy, the American is at no loss to serve up
a handsome list of shortcomings to the other side. He has observed
and, perhaps overestimating, he detests the spirit of caste, the
existence of those restrictions which wrongfully hamper one
individual and as undeservedly advantage another. Again, the
American hates bureaucracy and he hates militarism. The idea of
highest authority being vested in a man for any other reason than
that of his individual qualifications goes against all his convictions;
and his moral feeling knows no more detestable breed of man than
the incompetent aspirant who is servile with his superiors and brutal
to his inferiors. It is typically un-American. And if, in contrast to this,
one tries to do justice to the proved advantages of monarchy, of
aristocracy and the spirit of caste, to justify the ruler who stands
above the strife of parties, and to defend that system of symbols by
which the sentiment of the past is perpetuated in a people, and the
protection which is instituted for all the more ideal undertakings
which surpass the comprehension of the masses, or if one urges the
value of that high efficiency which can arise only from compact
political organization—then the American citizen swells with
contempt. What does he care for all that if he loses the inestimable
and infinite advantage which lies in the fact that in his state every
individual takes an active hand, assumes responsibility, and fights for
his own ideals? What outward brilliancy of achievement would
compensate him for that moral value of co-operation, initiative, self-
discipline, and responsibility, which the poorest and meanest citizen
enjoys? It may be that an enlightened and well-meaning monarch
sees to it that the least peasant can sit down to his chicken of a
Sunday; but God raised up the United States as an example to all
nations, that it shall be the privilege of every man to feel himself
responsible for his town, county, state, and country, and even for all
mankind, and by his own free initiative to work to better them. The
strife of parties would better be, than that a single man should be
dead to the welfare of his country; and it is good riddance to
aristocracy and plenty, if a single man is to be prevented from
emulating freely the highest that he knows or anywise detained from
his utmost accomplishment.
All such speculative estimates of different constitutional forms lead
to no result unless they take into account the facts of history. Every
side has its good and evil. And all such discussions are the less
productive in that superiorities of constitution, although soundly
argued, may or may not in any given country be fully made use of,
while on the other hand defects of constitution are very often
obviated. Indeed, to take an example from present tendencies in
America, nothing is more characteristic than the aristocratic by-
currents through which so many dangers of democracy are avoided.
Officially, of course, a republic must remain a democracy, otherwise
it mines its own foundations, and yet we shall see that American
social and political life have developed by no means along parallel
lines but rather stand out often in sharp contrast. The same is true
of Germany. Official Germany is aristocratic and monarchic through
and through, and no one would wish it other; but the intimate life of
Germany becomes every day more democratic, and thus the natural
weaknesses of an aristocracy are checked by irresistible social
counter-tendencies. It may have been the growing wealth of
Germany which raised the plane of life of the middle classes; or the
industrial advance which loaned greater importance to manufacturer
and merchant, and took some social gloss from the office-holding
class; it may have been the colonial expansion which broadened the
horizon and upset a stagnant equilibrium of stale opinion; or, again,
the renewed efforts of those who felt cramped and oppressed, the
labourers, and, above all, the women; it does not matter how it
arose—a wave of progress is sweeping over that country, and a
political aristocracy is being infused with new, democratic blood.
Now in America, as will often appear later, the days are over in
which all aristocratic tendencies were strictly held back. The
influence of intellectual leaders is increasing, art, science, and the
ideals of the upper classes are continually pushing to the front, and
even social lines and stratifications are beginning more and more to
be felt. The soul of the people is agitated by imperialistic and
military sentiments, and whereas in former times it was bent on
freeing the slaves it now discovers “the white man’s burden” to lie in
the subjugation of inferior races. The restrictions to immigration are
constantly being increased. Now of course all this does not a whit
prejudice the formal political democracy of the land; it is simply a
quiet, aristocratic complement to the inner workings of the
constitution.
The presence, and even the bare possibility, here, of such by-
currents, brings out more clearly how hopeless the theoretical
estimation of any isolated form of statehood is, if it neglects the
factors introduced by the actual life of the people. The American
democracy is not an abstractly superior system of which a European
can approve only by becoming himself a republican and
condemning, incidentally, his own form of government: it is rather,
merely, the necessary form of government for the types of men and
the conditions which are found here. And any educated American of
to-day fully realizes this. No theoretical hair-splitting will solve the
problem as to what is best for one or another country; for that true
historical insight is needed. And even when the histories of two
peoples are so utterly dissimilar as are those of America and
Germany, it by no means follows, as the social by-currents just
mentioned show, that the real spirit of the peoples must be unlike.
Democratic America, with its unofficial aristocratic leanings, has, in
fact, a surprising kinship to monarchical Germany, with its inner
workings of a true democracy. The two peoples are growing into
strong resemblance, although their respective constitutions flourish
and take deeper root.
The beginnings of American history showed unmistakably and
imperatively that the government of the American people must be,
in the words of Lincoln, “a government of the people, by the people,
and for the people.” No one dreamed when the Constitution of the
United States was framed, some hundred and seventeen years ago,
that this democratic instrument would ever be called on to bind
together a mighty nation extending from Maine to California. And,
indeed, such a territorial expansion would undoubtedly have
stretched and burst the unifying bonds of this Constitution, if the
distance between Boston and San Francisco had not meanwhile
become practically shorter than the road from Boston to Washington
was in those early days. But that this Constitution could so adapt
itself to the undreamt broadening of conditions, that it could
continue to be the mainstay of a people that was indefinitely
extending itself by exchange and purchase, conquest and treaty, and
that in no crisis has an individual or party succeeded in any
tampering with the rights of the people; all this shows convincingly
that the American form of state was not arbitrarily hit on, but that it
was the outcome of an historical development.

The spirit of this commonwealth was not first conceived in the year
1787. It was strong and ripe long before the delegates from the
Thirteen States assembled under Washington’s leadership in
Independence Hall at Philadelphia. The history of the English
colonists to the Atlantic coast shows from the very first what weight
they attached to the duties and rights of the individual, and foretells
as well the inevitable result, their unloosing from the mother country
and final declaration of their independence.
We may consider the different lines of development which began
early in the seventeenth century, after the feeble attempts at
colonization from England, France and Spain in the latter half of the
sixteenth century had miscarried and left socially no traces. French
settlements flourished as early as 1605, chiefly however in Nova
Scotia and other parts of Canada, and in 1609 settlements of Dutch,
whose colony on the Hudson River, the present New York, soon
passed over into English hands. The development of the Spanish
colonies on the Gulf of Mexico went on outside the territory of these
young United States; and so the story of the meagre years of
America is comprised in the history of the English colonies alone.
These colonies began diversely but came to resemble one another
more and more as time went on. There can be no greater contrast
than between the pioneer life of stout-willed men, who have left
their native soil in order to live in undisturbed enjoyment of their
Puritan faith, seeking to found their little communities on simple
forms of self-government, and on the other hand the occupation of a
rich trading company under royal charter, or the inauguration of a
colony of the crown. But these differences could not be preserved.
The tiny independent communities, as they grew in consideration,
felt the need of some protecting power and therefore they looked
once more to England; while, on the other hand, the more powerful,
chartered colonies tended to loose themselves from the mother
country, feeling, as they soon did, that their interests could not be
well administered from across a broad ocean. In spite of the
protecting arm of England, they felt it to be a condition of their
sound growth that they should manage their domestic affairs for
themselves. Thus it happened that all the colonies alike were
externally dependent on England, while internally they were
independent and were being schooled in citizenship.
The desire for self-government as a factor in the transformations
which went on can very easily be traced; but it would be harder to
say how far utilitarian and how far moral factors entered in. Virginia
took the first step. Its first settlement of 1606 was completely
subject to the king, who granted homesteads but no political rights
to the colonists. It was a lifeless undertaking until 1609, when its
political status was changed. The administration of the colony was
entrusted to those who were interested in its material success. It
became a great business undertaking which had everything in its
favour. At the head was a London company, which for a nominal sum
had been allowed to purchase a strip of land having four hundred
miles of seacoast and extending inland indefinitely. This land
contained inestimable natural resources, but needed labour to
exploit them. The company then offered to grant homes on very
favourable terms to settlers, receiving in return either cash or
labour; and these inducements, together with the economic pressure
felt by the lower classes at home, brought about a rapid growth of
the colony. Now since this colony was organized like a military
despotism, whose ruler, however, was no less than three thousand
miles away, the interests of the company had to be represented by
officials delegated to live in the colony. The interests of these
officials were of course never those of the colonists, and presently,
moreover, unscrupulous officials commenced to misuse their power;
so that as a result, while the colony flourished, the company was on
the brink of failure. The only way out of this difficulty was to
concede something to the colonists themselves, and harmonize their
interests with those of the company by granting them the free
direction of their own affairs. It was arranged that every village or
small city should be a political unit and as such should send two
delegates to a convention which sat to deliberate all matters of
common concern. This body met for the first time in 1619; and in a
short time it happened, as was to be expected, that the local
government felt itself to be stronger than the mercantile company
back in London. Disputes arose, and before five years the company
had ceased to exist, and Virginia became a royal province. But the
fact remained that in the year 1619 for the first time a deliberative
body representing the people had met on American soil. The first
step toward freedom had been taken. And with subtle irony fate
decreed that in this same year of grace a Dutch ship should land the
first cargo of African negroes in the same colony, as slaves.
That other form of political development, which started in the
voluntary compact of men who owned no other allegiance, was first
exemplified in the covenant of those hundred and two Puritans who
landed from the Mayflower at Plymouth, in the year 1620, having
forsaken England in order to enjoy religious freedom in the New
World. A storm forced them to land on Cape Cod, where they
remained and amid the severest hardships built up their little colony,
which, as no other, has been a perpetual spring of moral force. Even
to-day the best men of the land derive their strength from the moral
courage and earnestness of life of the Pilgrims. Before they landed
they signed a compact, in which they declared that they had made
this voyage “for ye glory of God and advancement of ye Christian
faith, and honour of our King and countrie,” and that now in the
sight of God they would “combine ... togeather into a civil body
politik for our better ordering and preservation and furtherance of ye
end aforesaid, and by vertue hearof to enacte, constitute and frame
such just and equal lawes, ordinances, actes, constitutions and
offices from time to time, as shall be thought most meete and
convenient for ye generall good of ye colonie.”
The executive was a governor and his assistants, elected annually
from the people: while the power to make laws remained with the
body of male communicants of the church. And so it remained for
eighteen years, until the growth of the colony made it hard for all
church-members to meet together, so that a simple system of
popular representation by election had to be introduced. This colony
united later with a flourishing trading settlement, which centred
about Salem; and these together formed the Massachusetts Bay
Colony, which in 1640 numbered already twenty thousand souls.
The covenant which was drawn up on board the Mayflower is to be
accounted the first voluntary federation of independent Americans
for the purposes of orderly government. The first written constitution
was drawn up in the colony of Connecticut, a colony which repeated
essentially the successful experiments of New Plymouth, and which
consisted of agricultural settlements and small posts for trading with
the Indians situated at Windsor and Hartford and other places along
the Connecticut Valley. Led by common interests, they adopted in
1638 a formal constitution.
There was still a third important type of colonial government, which
was at first thoroughly aristocratic and English, and nevertheless
became quickly Americanized. It was the custom of the King to grant
to distinguished men, under provision of a small tribute, almost
monarchical rights over large tracts of land. The first such man was
Lord Baltimore, who received in 1632 a title to the domain of
Maryland, on the Chesapeake Bay. He enjoyed the most complete
princely prerogatives, and pledged to the crown in return about a
fifth part of the gold and silver mined in his province. In 1664
Charles the Second gave to his brother, the Duke of York, a large
territory, which was soon broken up, and which included what are
now known as the States of Vermont, New Jersey, and Delaware.
The great provinces of Georgia and Carolina—now North and South
Carolina—were awarded by the same King to one of his admirals, Sir
William Penn, for certain services. Penn died, and his son, who found
himself in need of the sixteen thousand pounds which his father had
loaned to the King, gratified that monarch by accepting in their stead
a stretch of coast lands extending between the fortieth and forty-
third degrees of latitude.
In this way extensive districts were turned over to the caprice of a
few noblemen; but immediately the spirit of self-direction took
everywhere root, and a social-political enthusiasm proceeded to
shape the land according to new ideals. Carolina took counsel of the
philosopher, Locke, in carrying out her experiment. Maryland, which
was immediately prospered with two hundred men of property and
rank, chiefly of Roman Catholic faith, started out with a general
popular assembly, and soon went over to the representative system.
And Penn’s constructive handiwork, the Quaker State of
Pennsylvania, was intended from the first to be “a consecrated
experiment.” Penn himself explained that he should take care so to
arrange the politics of his colony that neither he himself nor his
successors should have an opportunity to do wrong. Penn’s
enthusiasm awoke response from the continent: he himself founded
the “city of brotherly love,” Philadelphia; and Franz Daniel Pastorius
brought over his colony of Mennonites, the first German settlers,
who took up their abode at Germantown.
Thus it was that the spirit of self-reliant and self-assertive
independence took root in the most various soils. But that which led
the colonies to unite was not their common sentiments and
ambitions, but it was their common enemies. In spite of the
similarity of their positions there was no lack of sharp contrasts. And
perhaps the most striking of these was the opposition between the
southern colonies, with their languid climate, where the planters left
all the work to slaves, and the middle and northern provinces, where
the citizens found in work the inspiration of their lives. The foes
which bound together these diverse elements were the Indians, the
French, the Spanish, and lastly their parent race, the English.
The Indian had been lord of the land until he was driven back by the
colonists to remoter hunting territory. The more warlike tribes tried
repeatedly to wipe out the white intruder, and constantly menaced
the isolated settlements, which were by no means a match for them.
Soon after the first serious conflict in 1636, the Pequot war, Rhode
Island, which was a small colony of scattered settlements, made
overtures toward a protective alliance with her stronger neighbours.
In this she was successful, and together with Massachusetts,
Plymouth, New Haven, and Connecticut, formed the United Colonies
of New England. This union was of little practical importance except
as a first lesson to the colonies to avoid petty jealousies and to
consider a closer mutual alliance as a possibility which would by no
means impair the freedom and independence of the uniting parties.
The wars with the French colonies had more serious consequences.
The French, who were the natural enemies of all English
settlements, had originally planted colonies only in the far north, in
Quebec in 1608. But during those decades in which the English
wayfarers were making homes for themselves along the Atlantic
coast, the French were migrating down from the north through the
valley of the Saint Lawrence and along the Great Lakes to the
Mississippi River. Then they pressed on down this stream to its
mouth and laid title to the tremendous tracts which it drains, in the
name of the French crown. This country they called after King Louis
XIV, Louisiana. They had not come as colonists, but solely with an
eye to gain, hoping to exploit these untouched resources in behalf of
the Canadian fur traffic; and close on the heels of the trader came
the Catholic priest. Thus the territory that flanked the English
colonies to inland fell into French hands, whereas the land-grants of
the English crown so read that only the Pacific Ocean should be the
western boundary. A collision was therefore inevitable, although
indeed mountains and virgin forests separated the coastland
settlements from the inland regions of the Mississippi where the
French had planted and fortified their trading posts.
When, in 1689, war broke out in Europe between England and
France, a fierce struggle began between their representatives in the
New World. But it was not now as it had been in the Indian war,
where only a couple of colonies were involved. All the colonies along
the coast were threatened by a common enemy. A congress of
delegates convened at New York in April of 1690, in which for the
first time all the colonies were invited to take part. Three long wars
followed. The greatest advantage on the French side was that from
the first they had been on good terms with the Indians, whose aid
they were now able to enlist. But the French were numerically weak,
and received but little assistance from their mother country. When in
1766 the last great war broke out the English colonies had a
population of a million and a quarter, while the French had only a
tenth as many. Chiefly and finally, the English colonists were actual
settlers, hardened and matured through carrying the responsibilities
of their young state, and fighting for hearth and home; the French
were either traders or soldiers. The principle of free government was
destined on this continent to triumph. Washington, then a young
man, led the fight; the English Secretary of State, William Pitt, did
everything in his power to aid; and the victory was complete. By the
treaty of 1763 all French possessions east of the Mississippi were
given to England, with the exception of New Orleans, which,
together with the French possessions west of the Mississippi, went
to Spain. Spain meanwhile ceded Florida to England. Thus the entire
continent was divided between England and Spain.
But the Seven Years War had not merely altered the map of
America; it had been an instructive lesson to the colonists. They had
learned that their fortunes were one; that their own generals and
soldiers were not inferior to any which England could send over; and
lastly, they had come to see that England looked at the affairs of the
colonies strictly from the point of view of her own gain. Herewith
was opened up a new prospect for the future: the French no longer
threatened and everything this side of the Mississippi stood open to
them and promised huge resources. What need had they to depend
further on the English throne? The spirit of self-direction could now
consistently come forward and dictate the last move.
It is true that the colonists were still faithful English subjects, and in
spite of their independent ambitions they took it for granted that
England would always direct their foreign policy, would have the
right to veto such laws as they passed, and that the English
governors would always be recognized as official authorities. But
now the English Parliament planned certain taxations that were the
occasion of serious dispute. The Thirteen Colonies, which in the
meantime had grown to be a population of two million, had by their
considerable war expenditures shown to the debt-encumbered
Britons the thriving condition of colonial trade. And the latter were
soon ready with a plan to lay a part of the public taxation on the
Americans. It was not in itself unfair to demand of the colonies some
contribution to the public treasury, since many of the expenditures
were distinctly for their benefit; and yet it must have seemed
extraordinary to these men who had been forced from childhood to
shift for themselves, and who believed the doctrine of self-
government to be incontrovertible. They objected to paying taxes to
a Parliament in which they had no representation; and the phrase,
“no taxation without representation,” became the motto of the hour.
The Stamp Tax, which prescribed the use of revenue stamps on all
American documents and newspapers, was received with
consternation, and societies called the Sons of Freedom were formed
throughout the land to agitate against this innovation. The Stamp
Tax Congress, which met in New York in 1765, repudiated the law in
outspoken terms. Nor did it halt with a mere expression of opinion;
the spirit of self-direction was not to be molested with impunity.
Close on the resolve not to observe the law, came the further
agreement to buy no English merchandise. England had to waive the
Stamp Tax, but endless mutterings and recriminations followed
which increased the bitterness. Both sides were ripe for war when,
in 1770, England issued a proclamation laying a tax on all tea
imported to the colonies. The citizens of Boston became enraged
and pitched an English ship-load of tea into the harbour. Thereupon
England, equally aroused, proceeded to punish Boston by passing
measures designed to ruin the commerce of Boston and indeed all
Massachusetts. The Thirteen Colonies took sides with Massachusetts
and a storm became imminent. The first battle was fought on the
19th of April, 1775; and on July 4th, 1776, the Thirteen Colonies
declared their independence of England. Henceforth there were to
be no colonies but in their place thirteen free states.
The Declaration of Independence was composed by Jefferson, a
Virginian, and is a remarkable document. The spirit that informs it is
found in the following lines: “We hold these truths to be self-evident,
that all men are created equal; that they are endowed by their
Creator with certain unalienable rights; that among these are life,
liberty, and the pursuit of happiness. That to secure these rights,
governments are instituted among men, deriving their just powers
from the consent of the governed....” The sins of the English king
and people against America are enumerated at length, and in
solemn language the United States of America are declared
independent of the English people, who are henceforth to be as “the
rest of mankind, enemies in war, in peace friends.” This Declaration
was signed by delegates from the states in Independence Hall, in
Philadelphia, where hung the famous bell, with its inscription,
“Proclaim liberty throughout all the land, unto all the inhabitants
thereof.”
The spirit of self-direction had triumphed; but the dangers were by
no means wholly passed. England sent over no more governors, and
had indeed been repulsed; but she had as yet no intention of giving
in. The war dragged on for five long years, and the outcome was
uncertain until in 1781 Cornwallis was brought to surrender. Then
England knew that she had lost the contest. The king desired still to
prolong the war, but the people were tired of it and, the ministry
having finally to yield, peace was declared in April of the year 1783.
This was no assurance of an harmonious future, however. That
solidarity which the colonies had felt in the face of a common enemy
now gave way to petty jealousies and oppositions, and the inner
weakness of the new Union was revealed. In itself the Union had no
legal authority over the several states, and while during the war the
affairs of the country had fallen into disorder, yet the Union had no
power to conduct foreign diplomacy or even to collect customs.
It was rather in their zeal for self-direction that at first considerable
portions of the population seemed disinclined to enlarge the
authority of the central organization. Self-direction begins with the
individual or some group of individuals. The true self-direction of
society as a whole was not to be allowed to encroach on the rights
of the individual, and this was the danger feared. Each state, with its
separate interests and powers, would not give up its autonomy in
favour of an impersonal central power which might easily come to
tyrannize over the single state in much the same way as the hated
English throne had done. And yet the best men of the country were
brought at length more and more to the opposite view; a strong
central authority, in which the states as a whole should become a
larger self-directing unit, carrying out and ensuring the self-direction
of the component members, was seen to be a necessity. Another
congress of representatives from all the states was convened in
Independence Hall, at Philadelphia, and this body of uncommonly
able men sat for months deliberating ways by which the opposing
factions of federalism and anti-federalism could be brought together
in a satisfactory alliance. It was obvious that compromises would
have to be made. So, for instance, it was conceded that the smallest
state, like the largest, should be represented in the senate by two
delegates: and the single state enjoyed many other rights not usual
in a federation. But, on the other hand, it was equally certain that
the chief executive must be a single man with a firm will, and that
this office must be refilled at frequent intervals by a popular election.
A few had tentatively suggested making Washington king, but he
stood firm against any such plan. The republican form of
government was in this instance no shrewdly devised system which
was adopted for the sake of nicely spun theoretical advantages—it
was the necessity of the time and place, the natural culmination of a
whole movement. It was as absolutely necessary as the
consolidation of the German states, eighty years later, under an
imperial crown. The congress eventually submitted a constitutional
project to the several state legislatures, for their summary approval
or rejection. Whereon the anti-federalistic factions made a final
effort, but were outvoted, and the Constitution was adopted. In
1789 George Washington was elected the first president of the
United States.
It would take a lively partisan to assert, as one sometimes does, that
this Constitution is the greatest achievement of human intellect, and
yet the severest critics have acknowledged that a genius for
statesmanship is displayed in its text. Penned in an age which was
given over to bombastic declamation, this document lays down the
fundamental lines of the new government with great clearness and
simplicity. “We, the people of the United States,” it begins, “in order
to form a more perfect union, establish justice, insure domestic
tranquillity, provide for the common defence, promote the general
welfare, and secure the blessings of liberty to ourselves and our
posterity, do ordain and establish this Constitution for the United
States of America.” This is the entire introduction. The contents
come under seven articles. The first article provides for the making
of laws, this power to be vested in a Congress consisting of a Senate
and House of Representatives; for the business and daily routine of
this Congress, as well as its powers and obligations. The second
article provides for the executive power, to be vested in the person
of the President, who is elected every fourth year; the third article
provides for a judiciary; the fourth defines the mutual relations of
separate states; and the last three articles concern the adoption of
the Constitution and the conditions under which it may be amended.
The need of amendments and extensions to this Constitution was
foreseen and provided for. How profoundly the original document
comprehended and expressed the genius of the American people
may be seen from the fact that during a century which saw an
unexampled growth of the country and an undreamed-of
transformation of its foreign policy, not a single great principle of the
Constitution was modified. After seventy-seven years one important
paragraph was added, prohibiting slavery; and this change was
made at a tremendous cost of blood. Otherwise the few
amendments have been insignificant and concerned matters of
expediency or else, and more specially, further formulations of what,
according to American conceptions, are the rights of the individual.
Although the original Constitution did not contain a formal
proclamation of religious freedom, freedom of speech, of the press,
and of public assemblage, this was not because those who signed
the document did not believe in these things, but because they had
not aimed to make of the Constitution of the Union either a treatise
on ethics or yet a book of law. But as early as 1789 the states
insisted that all the rights of the individual, as endorsed by the
national ideals, should be incorporated in the articles of this
document. In the year 1870 one more tardy straggler was added to
the list of human rights, the last amendment; the right of the
citizens to vote was not to be abridged on account of race, colour, or
previous condition of servitude.
Of the other amendments, the tenth had been tacitly assumed from
the first year of the Republic; this was that “The powers not
delegated to the United States by the Constitution, nor prohibited by
it to the States, are reserved to the States respectively, or to the
people.” This principle also was surely in no way at variance with the
spirit of the original document. It was, indeed, the lever that
ensured the great efficacy of the Constitution, so that by its
provisions the centrifugal forces were never disturbed by centripetal
ones; an equilibrium was effected between the tendencies that made
for unity and those that made against it, in such a way that the
highest efficiency was ensured to the whole while the fullest
encouragement was given to the enterprise and initiative of the
parts. In no direction, probably, would an improvement have been
possible. More authority concentrated at the head would have
impeded general activity, and less would have lost the advantages of
concerted action; in neither case would material growth or the
reconciliation of conflicting opinions have been possible. Constant
compensation of old forces and the quickening of new ones were the
secret of this documented power, and yet it was only the complete
expression of the spirit of self-direction, which demands
unremittingly that the nation as a whole shall conduct itself without
encroaching on the freedom of the individual, and that the individual
shall be free to go his own ways without interfering with the
unfettered policy of the nation.
Under the auspices of this Constitution the country waxed and
throve. As early as 1803 its land area was doubled by the accession
of Louisiana, which had been ceded by Spain to France, and was
now purchased from Napoleon for fifteen million dollars—an event of
such far-reaching importance that the people of St. Louis have not
inappropriately invited the nations of the earth to participate in a
Louisiana Purchase Exposition. In 1845 Texas was taken into the
Union, it having broken away from Mexico just previously and
constituted itself an independent state. The large region on the
Pacific slope known as Oregon came in 1846 to the United States by
treaty with England, and when finally, in 1847, after the war with
Mexico, New Mexico and California became the spoils of the victor
and in 1867 Russia relinquished Alaska, the domain of the country
was found to have grown from its original size of 324,000 square
miles to one of 3,600,000. The thirteen states had become forty-five,
since the newly acquired lands had to be divided. But all this growth
brought no alteration in the Constitution, whose spirit of self-
direction, rather, had led to this magnificent development, had
fortified and secured the country, and inspired it with energy and
contentment. The population also has grown under this benevolent
Constitution. Millions have flocked hither to seek and to find
prosperity on this new and inexhaustible soil. The area has increased
tenfold, but the population twenty-fold; and the newcomers have
been disciplined in the school of self-direction and educated to the
spirit of American citizenship.

There is a certain kind of character which must be developed in this


school. It is true, of course, that there is no one model which just
fits every one, the native-born Yankee as well as the European
immigrant, the farmer as well as the resident in cities. The Irish-
American is not the German-American, nor is the New Englander like
the Virginian, nor the son of the East like his brother in the West.
The infinite shadings of personal character, temperament, and
capacity which nature has produced, have, of course, not been lost.
And, nevertheless, just as the human race in America has begun to
differentiate into a species which is anthropologically distinct, and
this partly under the influence of the climate since the species has
several characters in common with the aboriginal Indian, so also in
the moral atmosphere of this body-politic a distinct type of human
character is undoubtedly being evolved; and one may note with
perpetual surprise how little the other great divisions of social life, as
of rich and poor, cultivated and ignorant, native-born and immigrant,
manual labourer and brain-worker—how little these differentiate the
American citizen in his political capacity. Of course only the political
life is in question here; that new groupings and divisions are being
continually formed in the economic, intellectual, and social life need
not concern us for the present. In the individual it may not be easy
to follow the threads through the tissue of his psychic motions, but
in the abstract and schematic picture of the type it is by no means
impossible to trace them out.
What is it, then, which the American has gotten from his training?
Many and apparently unrelated lessons are taught in the school of
self-direction, and perhaps none of them are without their dangers.
For it is here not a matter of theoretical knowledge, which may be
remembered or forgotten and may be well or ill selected, but which
in itself involves no scale of excellence and, therefore, has no need
to be tempered or restrained. Theoretical knowledge cannot be
overdone or exaggerated into untruth. But the practical conduct
which is here in question is different; it involves an ideal, and in such
a way that a man may not only misapprehend or forget what is the
best course of action, but also he may err in following it, he may
give it undue place and so neglect opposing motives which in their
place are no less requisite. In short, conduct, unlike knowledge,
demands a fine tact and unflagging discernment for the fitness of
things. In this sense it cannot be denied that the teaching of
American democracy is itself the source of serious errors, and that
the typical American citizen is by no means free from the failings of
his virtues. His fundamental traits may be briefly sketched, and from
the excellencies which he strives for many of his defects can be
understood.
There is, firstly, a group of closely related impulses, which springs
from the American’s unbounded belief in his own strength, a trait
which in the last analysis must be, of course, the foundation-stone
of any doctrine of self-direction. He will not wait for others to look
out for him, counsel him, or take cognizance of his interests, but
relies wholly on his own judgment and his own strength, and
believes no goal too high for his exertions to attain. Every true
American will have found in himself some trace of this spirit. Each
day of his life has suggested it to him, and all the institutions of his
country have reinforced the teaching. Its most immediate result is
such a strength of initiative as no other people on earth possesses,
an optimism, a self-reliance and feeling of security which contribute
more than half to his success. Faint heart is not in the American’s
dictionary. Individual, corporation, or country may be undecided, and
dispute whether a certain end is desirable or whether a certain
means is best to a given end, but no one ever doubts or goes into
his work with misgivings lest his strength be not enough to traverse
the road and reach the goal. And such an attitude encourages every
man to exert himself to the utmost. The spirit of self-direction is
here closely allied with that self-initiative which is the mainspring of
the economic life of America. But the initiative and optimistic
resolution shown in the political arena astonish the stranger more
than the same traits displayed in the economic field. It is shown in
the readiness for argument, in which every one can express himself
accurately and effectively; in the indefatigable demand that every
public office shall be open to the humblest incumbent, and in the
cool assurance with which thousands and thousands of persons,
without any technical knowledge or professional training, assume the
most exacting political offices, and become postmasters, mayors,
ministers and ambassadors, without even pausing before their grave
responsibilities. But most of all, American initiative is shown in the
structure of all her institutions, great or small, which minimizes
transitions and degrees between higher and lower, and so facilitates
the steady advance of the individual. Each and all must have the
chance to unfold and there must be no obstacles to hinder the right
ambition from its utmost realization. Every impulse must be utilized;
and however far toward the periphery a man may be born he must
have the right of pressing forward to the centre. The strength of this
nation lies at the periphery, and the American government would
never have advanced so unerringly from success to success if every
village stable-lad and city messenger-boy had not known with pride
that it depends only on himself if he is not to become President of
the United States.
But the transition is easy and not well marked from such strength to
a deplorable weakness. The spirit of initiative and optimism is in
danger of becoming inexcusable arrogance as to one’s abilities and
sad underestimation of the value of professional training.
Dilettanteism is generally well-meaning, often successful, and
sometimes wholly admirable; but it is always dangerous. When
brawny young factory-hands sit on a school committee, sturdy
tradesmen assume direction of a municipal postal service, bankers
become speakers in legislature, and journalists shift over to be
cabinet ministers, the general citizen may sometimes find cold
comfort in knowing that the public service is not roped off from
private life, nor like to become effete through stale traditions. It is
very evident that America is to-day making a great effort to ward off
the evils of amateurish incompetence and give more prominence to
the man of special training. And yet it cannot be denied that very
noticeably in the intellectual make-up of the American his free
initiative and easy optimism are combined with a readiness to
overestimate his own powers and with a bias for dilettanteism.
Another psychological outcome of this individualism seems
inevitable. When every member of a nation feels called on to pass
judgment on all subjects for himself, it will come about that public
opinion reaches an uncommonly high mean level, but it will also
happen that the greatest intellects are not recognized as being
above this mean. The genius, who in his day is always
incomprehensible to the masses, goes to waste; and the man who
sees beyond the vulgar horizon fights an uphill battle. The glittering
successes are for the man whose doings impress the multitude, and
this fact is necessarily reflected in the mind of the aspirant, who
unconsciously shapes his ambitions to the taste of the many rather
than of the best. Wherever the spirit of initiative possesses all alike,
a truly great individual is of course insufferable; any great advance
must be a collective movement, and the best energies of the country
must be futilely expended in budging the masses. It is no accident
that America has still produced no great world genius. And this is the
other side of the vaunted and truthful assertion, that whenever in a
New England town a question is brought to an open debate, the
number of those who will take a lively, earnest, orderly, and
intelligent part in the discussion is perhaps greater in proportion to
the total number of inhabitants than in any place in Europe.
This leads us to a second consequence of the desire for self-
direction. It stimulates not only initiative and self-reliance, but also
the consciousness of duty. If a man earnestly believes that the
subject must also be potentate, he will not try to put off his
responsibilities on any one else but will forthwith set himself to work,
and prescribe as well his own due restrictions. If a neighbourhood or
club, town, city, or state, or yet the whole federation sees before it
some duty, the American will not be found waiting for a higher
authority to stir him up, for he is himself that authority; his vote it is
which determines all who are to figure in the affair. Wherefore he is
constrained by the whole system to an earnest and untiring co-
operation in everything. This is not the superficial politics of the ale-
house, with its irresponsible bandying of yeas and nays. When
Secretary of the Navy under McKinley, Mr. Long said that when the
cabinet at Washington was in conference, every member was of
course better posted on the matter than the average citizen; but
that nevertheless a dozen villagers, say in northern Maine, would
read their New York and Boston papers and talk over the affairs with
as much intelligence and as good a comprehension of the points at
issue as would appear at any cabinet debates. This was by no
means meant as a reflection on his colleagues of the cabinet, but as
a frank recognition of an aspect of American life which invariably
surprises the foreigner. One needs only to recall the discussion which
preceded the last presidential election, and more especially the one
preceding that; the silver question was the great issue, and evening
after evening hundreds of thousands listened to technical arguments
in finance such as no European orator could hope to lay before a
popular assembly. Huge audiences followed with rapt attention for
hours lectures on the most difficult points of international monetary
standards. And this intellectual seriousness springs from the feeling
of personal responsibility which is everywhere present. The
European is always astonished at the exemplary demeanour of an
American crowd; how on public occasions great multitudes of men
and women regulate their movements without any noticeable
interference by the police, how the great transportation companies
operate with almost no surveillance of the public, trusting each
person to do his part, and how in general the whole social structure
is based on mutual confidence to a degree which is nowhere the
case in Europe. The feeling that the ruler and the ruled are one
pervades all activities, and its consequences are felt far beyond the
political realm. Especially in the social sphere it makes for self-
respect among the lower classes; they adapt themselves readily to
discipline, for at the same time they feel themselves to be the
masters; and the dignity of their position is the best security for their
good behaviour.
But here, too, excellence has its defects. Where every one is so
intensely aware of an identity between political authority and
political subject, it is hard for the feeling of respect for any person
whatsoever to find root. The feeling of equality will crop out where
nature designed none, as for instance between youth and mature
years. A certain lack of respect appears in the family and goes
unpunished because superficially it corresponds to the political
system of the land. Parents even make it a principle to implore and
persuade their children, holding it to be a mistake to compel or
punish them; and they believe that the schools should be conducted
in the same spirit. And thus young men and women grow up without
experiencing the advantages of outer constraint or discipline.
Hitherto we have considered only those intellectual factors derived
from the spirit of self-direction which bear on the will of the
individual, his rights and duties; but these factors are closely bound
up with the others which concern the rights and privileges of one’s
neighbour. We may sketch these briefly. Deeply as he feels his own
rights, the American is not less conscious of those of his neighbour.
He does not forget that his neighbour may not be molested and
must have every opportunity for development and the pursuit of his
ambitions, and this without scrutiny or supervision. He recognizes
the other’s equal voice and influence in public affairs, his equally
sincere sense of duty and fidelity to it. This altruism expresses itself
variously in practical life. Firstly, in a complete subordination to the
majority. In America the dissenting minority displays remarkable
discipline, and if the majority has formally taken action, one hears
no grumbling or quibbling from the discontented, whether among
boys at play or men who have everything at stake. The outvoiced
minority is self-controlled and good-natured and ready at once to
take part in the work which the majority has laid out; and herein lies
one of the clearest results of the American system and one of the
superior traits of American character.
Closely related to this is another trait which lends to American life
much of its intrinsic worth—the unconditional insistence in any
competition on equal rights for both sides. The demand for “fair
play” dominates the whole American people, and shapes public
opinion in all matters whether large or small. And with this, finally,
goes the belief in the self-respect and integrity of one’s neighbour.
The American cannot understand how Europeans so often reinforce
their statements with explicit mention of their honour which is at
stake, as if the hearer is likely to feel a doubt about it; and even
American children are often apt to wonder at young people abroad
who quarrel at play and at once suspect one another of some
unfairness. The American system does not wait for years of
discretion to come before exerting its influence; it makes itself felt in
the nursery, where already the word of one child is never doubted
by his playmates.
Here too, however, the brightest light will cast a shadow. Every
intelligent American is somewhat sadly aware that the vote of a
majority is no solution of a problem, and he realizes oftener than he
will admit that faith in the majority is pure nonsense if theoretical
principles are at issue. This is a system which compels him always
where a genius is required to substitute a committee, and to abide
by the majority vote. The very theory of unlimited opportunity has
its obvious dangers arising, here as everywhere, from extremes of
feeling and so exaggeration of the principle. The recognition of
another’s rights leads naturally to a sympathy for the weaker, which
is as often as not unjustified, and easily runs over into
sentimentalism, not to say an actual hysteria of solicitude. And this
is in fact a phase of public opinion which stands in striking contrast
to the exuberant health of the nation. What is even worse, the ever-
sensitive desire not to interfere in another’s rights leads to the
shutting of one’s eyes and letting the other do what he likes, even if
it is unjust. And in this way a situation is created which encourages
the unscrupulous and rewards rascality.
For a long time the blackest spot on American life, specially in the
opinion of German critics, has been the corruption in municipal and
other politics. We need not now review the facts. It is enough to
point out that a comparison with conditions in Germany, say, is
entirely misleading if it is supposed to yield conclusions as to the
moral character of the American people. Unscrupulous persons who
are keen for plunder, are to be found everywhere; merely the
conditions under which the German public service has developed
and now maintains itself make it almost impossible for a reprobate
of that sort to force his entrance. And if a German official were
discovered in dishonest practices it would be, in fact, discrediting to
the people. In America the situation is almost reversed. The
conditions on which, according to the American system, the lesser
officials secure their positions, specially in municipal governments,
and the many chances of enriching oneself unlawfully and yet
without liability to arrest, while the regular remuneration and above
all the social dignity of the positions are relatively small, drive away
the better elements of the population and draw on the inferior. The
charge against the Americans, then, should not be that they make
dishonest officials, but that they permit a system which allows
dishonest persons to become officials. This is truly a serious
reproach, yet it is not a charge of contemptible dishonesty but of
inexcusable complacency; and this springs from the national
weakness of leniency toward one’s neighbour, a trait which comes
near to being a fundamental democratic virtue. It cannot be denied,
moreover, that the whole nation is earnestly and successfully
working to overcome this difficulty.
The denunciations of the daily papers, however, must not be taken
as an indication of this, for the uncurbed American press makes the
merest unfounded suspicion an occasion for sensational accusations.
Any one who has compared in recent years the records of
unquestionably impartial judicial processes with the charges which
had previously been made in the papers, must be very sceptical as
to the hue and cry of corruption. Even municipal politics are much
better than they are painted. The easiest way of overcoming every
evil would be to remove the public service from popular and party
influences, but this is, of course, not feasible since it would
endanger the most cherished prerogatives of individualism. Besides,
the American is comforted about his situation because he knows that
just this direct efficiency of the people’s will is the surest means of
thoroughly uprooting the evil as soon as it becomes really
threatening. He may be patient or indifferent too long, but if he is
once aroused he finds in his system a strong and ready instrument
for suddenly overturning an administration and putting another in its
stead. Moreover, if corruption becomes too unblushing an
“educational campaign” is always in order. James Bryce, who is of all
Europeans the one most thoroughly acquainted with American party
politics, gives his opinion, that the great mass of civil officials in the
United States is no more corrupt than that of England or Germany.
An American would add, however, that they excel their European
rivals in a better disposition and greater readiness to be of service.
But the situation is complicated by still another tendency which
makes the fight for clean and disinterested politics difficult. The spirit
of self-direction involves a political philosophy which is based on the
individual; and the whole commonwealth has no other meaning than
an adding up of the rights of separate individuals, so that every
proposal must benefit some individual or other if it is to commend
itself for adoption. Now since the state is a collection of numberless
individuals and the law merely a pledge between them all, the
honour of the state and the majesty of the law do not attach to a
well organized and peculiarly exalted collective will, which stands
above the individual. Such a thing would seem to an individualist a
hollow abstraction, for state and law consist only in the rights and
responsibilities of such as he. From this more or less explicitly
formulated conception of political life there accrue to society both
advantages and dangers. The advantages are obvious: the
Mephistophelian saying, “Vernunft wird Unsinn, Wohltat Plage,”
becomes unthinkable, since the body-politic is continually tested and
held in check by the lively interests of individuals. Any obvious
injustice can be righted, for above the common weal stands the
great army of individuals by whom and for whom both state and law
were made.
But the disadvantages follow as well. If state and law are only a
mutual restraint agreed on between individuals, the feeling of
restraint becomes lively in proportion as the particular individuals in
question can be pointed to, but vanishingly weak when, in a more
intangible way, the abstract totality requires allegiance. So one finds
the finest feeling for justice in cases of obligation to an individual, as
in contracts, for instance, and the minimum sense of right where the
duty is toward the state. There is no country of Europe where the
sense of individual right so pervades all classes of the inhabitants, a
fact which stands in no wise contradictory to the other prevalent
tendency of esteeming too lightly one’s righteous obligations to city
or state. Men who, in the interests of their corporations, try to
influence in irregular ways the professional politicians in the
legislatures, observe nevertheless in private life the most rigid
principles of right; and many a one who could safely be trusted by
the widows and orphans of his city with every cent which they own,
would still be very apt to make a false declaration of his taxable
property.
There is a parallel case in the sphere of criminal law. Possibly even
more than the abuses of American municipal politics, the crimes of
lynch courts have brought down the condemnation of the civilized
world. Corruption and “lynch justice” are usually thought of as the
two blemishes on the nation, and it is from them that the casual
observer in Europe gets a very unfavourable impression of the
American conception of justice. We have already tried to rectify this
estimate in so far as it includes corruption, and as regards lynching it
is perhaps even more in error. Lynch violence is of course not to be
excused. Crime is crime; and the social psychologist is interested
only in deciding what rubric to put it under. Now the entire
development of lynch action shows that it is not the wanton violence
of men who have no sense of right, but rather the frenzied
fulfillment of that which we have termed the individualistic
conception of justice. The typical case of lynching is found, of
course, in Southern States with a considerable negro population. A
negro will have attempted violence on a white woman, whereon all
the white men of the neighbourhood, assuming that through the
influence of his fellow negroes the criminal would not be duly
convicted, or else feeling that the regular legal penalty would not
suffice to deter others from the same crime, violently seize the
culprit from out the jurisdiction of the law, and after a summary
popular trial hang him. But these are not men who are merely
seeking a victim to their brutal instinct for murder. It is reported that
after the deed, when the horrid crime has been horribly expiated,
the participants will quietly and almost solemnly shake one another
by the hand and disperse peacefully to their homes, as if they had
fulfilled a sacred obligation of citizenship. These are men imbued
with the individualistic notion of society, confident that law is not a
thing whose validity extends beyond themselves, but something
which they have freely framed and adopted, and which they both
may and must annul or disregard as soon as the conditions which
made it necessary are altered. It is a matter of course that such
presumption is abhorred and condemned in the more highly civilized
states of the Union, also by the better classes in the Southern
States; and a lyncher is legally a murderer. His deed, however, is not
to be referred psychologically to a deficient sense of justice. That
which is the foundation of this sense, resentment at an infringement
of the individual’s rights and belief in the connection between sin
and expiation, are all too vividly realized in his soul.
We have dwelt on these two offshoots of the individualistic idea of
law because they have been used constantly to distort the true
picture of American character. Rightly understood, psychologically,
these phenomena are seen to be black and ugly incidents, which
have little to do with the national consciousness of right and honour;
they are the regrettable accompaniments of an extreme
individualism, which in its turn, to be sure, grows naturally out of the
doctrine of self-direction. Every American knows that it is one of the
most sacred duties of the land to fight against these abuses, and yet
the foreigner should not be deceived into thinking, because so and
so many negroes are informally disposed of each year, and the
politicians of Philadelphia or Chicago continue to stuff their pockets
with spoils in ways which are legally unpunishable, that the
American is not thoroughly informed with a respect for law. He has
not taken his instruction in the system of self-direction in vain. And
the German who estimates the tone of political life in America by the
corruption and lynch violence narrated in the daily papers, is like the
American who makes up his opinion of the German army, as he
sometimes does, from the harangues of social democrats on the
abuses of military officers, or from sensational disclosures of small
garrisons on the frontier.
One more trait must be mentioned, finally, which is characteristic of
every individualistic community, and which, having been impressed
on the individual by the American system, has now reacted and
contributed much to the working out of this system. The American
possesses an astonishing gift for rapid organization. His highest
talents are primarily along this line, and in the same way every
individual has an instinct for stationing himself at the right place in
any organization. This is true both high and low, and can be
observed on every occasion, whether in the concerted action of
labouring men, in a street accident, or in any sort of popular
demonstration. For instance, one has only to notice how quickly and
naturally the public forms in orderly procession before a ticket-office.
This sure instinct for organization, which is such an admirable
complement to the spirit of initiative, gives to the American
workman his superiority over the European, for it is lamentably
lacking in the latter, and can be replaced only by the strictest
discipline. But this instinct finds its fullest expression in the political
sphere. It is this which creates parties, guarantees the efficiency of
legislatures, preserves the discipline of the state, and is in general
the most striking manifestation of the spirit of self-direction. But we
have seen that none of the merits of this system are quite without
their drawbacks, and this gift for organization has also its dangers.
The political parties which it fosters may become political
“machines,” and the party leader a “boss”—but here we are already
in the midst of those political institutions with which we must deal
more in detail.
CHAPTER TWO
Political Parties

T he Presidency is the highest peak in the diversified range of


political institutions, and may well be the first to occupy our
attention. But this chief executive office may be looked at in several
relations: firstly, it is one of the three divisions of the Government,
which are the executive, the legislative, and the judicial. And these
might well be considered in this order. But, on the other hand, the
President stands at the head of the federation of states; and the
structural beauty of the American political edifice consists in the
repetition of the whole in each part and of the part in every smaller
part, and so on down. The top governmental stratum of the
federation is repeated on a smaller scale at the head of each of the
forty-five states, and again, still smaller, over every city. The
governor of a state has in narrower limits the functions of the
President, and so, within still narrower, has the mayor of a city. We
might, then, consider the highest office, and after that its smaller
counterparts in the order of their importance.
But neither of these methods of treatment would bring out the most
important connection. It is possible to understand the President
apart from the miniature presidents of the separate states, or apart
from the Supreme Court, or even Congress, but it is not possible to
understand the President without taking account of the political
parties. It is the party which selects its candidate, elects him to
office, and expects from him in return party support and party
politics. The same is true, moreover, of elections to Congress and to
the state legislatures. For here again the party is the background to
which everything is naturally referred, and any description of the
President, or Congress, or the courts, which, like the original
Constitution, makes no mention of the parties, appears to us to-day
as lacking in plastic reality, in historical perspective. We shall,
therefore, attempt no such artificial analysis, but rather describe
together the constitutional government and the inofficial party
formations. They imply and explain each other. Then on this
background of party activities we can view more comprehensively
the President, Congress, the Supreme Court, and the entire politics
of the federation and the states.
We must not forget, however, that in separating any of these factors
from the rest, we deal at once with highly artificial abstractions, so
that this description will have continually to neglect many facts and
cut the threads that cross its path. The history of the American
Presidency shows at all times its close connection with other
institutions. A treaty or even a nomination by the President requires
the ratification of the Senate before it is valid; and on the other side,
the President can veto any bill of Congress. Even the Supreme Court
and the President can hardly be considered apart, as was seen, for
instance, in the time of Cleveland, when his fiscal policy took final
shape in an income tax which the Supreme Court declared
unconstitutional, and therefore unlawful; or again when the colonial
policy of McKinley was upheld and validated by a decision of the
same court. Again, the party politics of state and town are no less
intimately related to the federal government and the Presidency.
Here, too, the leadings are in both directions; local politics condition
the national, and these in turn dominate the local. Cleveland was a
man who had never played a part in national politics until he became
the executive head of the nation. As Mayor of Buffalo he had been
so conspicuous throughout the State of New York as to be elected
Governor of that state, and then in the state politics so won the
confidence of his party as to be nominated and elected to the
highest national office. McKinley, on the other hand, although he,
too, had been the Governor of a state, nevertheless gained the
confidence of his party during his long term of service in Congress.
Similarly it may be said that local politics are the natural path which
leads to any national position, whether that of senator or

Вам также может понравиться