0% found this document useful (0 votes)
13 views53 pages

Java Programming (Mindtap Course List), 10Th Edition Joyce Farrell - Ebook PDF

The document provides information about various Java programming eBooks available for download on ebookluna.com, including titles like 'Java Programming (MindTap Course List), 10th Edition' by Joyce Farrell. It includes links to download the eBooks in multiple formats such as PDF, ePub, and MOBI. Additionally, it contains copyright information and a brief overview of the contents covered in the Java programming textbook.

Uploaded by

haraesbutcon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views53 pages

Java Programming (Mindtap Course List), 10Th Edition Joyce Farrell - Ebook PDF

The document provides information about various Java programming eBooks available for download on ebookluna.com, including titles like 'Java Programming (MindTap Course List), 10th Edition' by Joyce Farrell. It includes links to download the eBooks in multiple formats such as PDF, ePub, and MOBI. Additionally, it contains copyright information and a brief overview of the contents covered in the Java programming textbook.

Uploaded by

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

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

com

Java Programming (MindTap Course List), 10th


Edition Joyce Farrell - eBook PDF

https://ebookluna.com/download/java-programming-mindtap-
course-list-10th-edition-ebook-pdf/

OR CLICK HERE

DOWLOAD NOW

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


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

Java Programming 9th Edition Joyce Farrell - eBook PDF

https://ebookluna.com/download/java-programming-ebook-pdf/

ebookluna.com

Programming Logic & Design, Comprehensive 9th edition


Joyce Farrell - eBook PDF

https://ebookluna.com/download/programming-logic-design-
comprehensive-9th-edition-ebook-pdf/

ebookluna.com

Programming Logic and Design, Comprehensive 9th Edition


Joyce Farrell - eBook PDF

https://ebookluna.com/download/programming-logic-and-design-
comprehensive-9th-edition-ebook-pdf/

ebookluna.com

Introduction to Java Programming, Comprehensive Version


10th edition- eBook PDF

https://ebookluna.com/download/introduction-to-java-programming-
comprehensive-version-ebook-pdf/

ebookluna.com
Physics for Scientists and Engineers (MindTap Course List)
10th Edition Serway - eBook PDF

https://ebookluna.com/download/physics-for-scientists-and-engineers-
mindtap-course-list-ebook-pdf/

ebookluna.com

Business Law: Text & Exercises (MindTap Course List) 10th


Edition Roger Leroy Miller - eBook PDF

https://ebookluna.com/download/business-law-text-exercises-mindtap-
course-list-ebook-pdf/

ebookluna.com

Your Career: How to Make it Happen (MindTap Course List)


10th Edition Lisa Owens - eBook PDF

https://ebookluna.com/download/your-career-how-to-make-it-happen-
mindtap-course-list-ebook-pdf/

ebookluna.com

Interpersonal Conflict 10th Edition Joyce L. Hocker -


eBook PDF

https://ebookluna.com/download/interpersonal-conflict-ebook-pdf/

ebookluna.com

(eBook PDF) Murach's Java Programming 5th Edition by Joel


Murach

https://ebookluna.com/product/ebook-pdf-murachs-java-programming-5th-
edition-by-joel-murach/

ebookluna.com
Java
Programming
Tenth Edition

Joyce Farrell

Australia • Brazil • Canada • Mexico • Singapore • United Kingdom • United States

Copyright 2023 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
This is an electronic version of the print textbook. Due to electronic rights restrictions,
some third party content may be suppressed. Editorial review has deemed that any suppressed
content does not materially affect the overall learning experience. The publisher reserves the right
to remove content from this title at any time if subsequent rights restrictions require it. For
valuable information on pricing, previous editions, changes to current editions, and alternate
formats, please visit www.cengage.com/highered to search by ISBN#, author, title, or keyword for
materials in your areas of interest.

Important Notice: Media content referenced within the product description or the product
text may not be available in the eBook version.

Copyright 2023 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
JavaTM Programming, Tenth Edition © 2023, © 2019, © 2016 Cengage Learning, Inc. WCN: 02-300
Joyce Farrell ALL RIGHTS RESERVED. No part of this work covered by the copyright herein
may be reproduced or distributed in any form or by any means, except as
SVP, Higher Education Product Management: Erin
permitted by U.S. copyright law, without the prior written permission of the
Joyner
copyright owner.
VP, Product Management, Learning Experiences: Unless otherwise noted, all content is Copyright © Cengage Learning, Inc.
Thais Alencar
Unless otherwise noted, all screenshots are courtesy of Microsoft Corporation.
Product Director: Mark Santee
Microsoft is a registered trademark of Microsoft Corporation in the U.S.
Associate Product Manager: Tran Pham and/or other countries.

The names of all products mentioned herein are used for identification
Product Assistant: Ethan Wheel
purposes only and may be trademarks or registered trademarks of their
Learning Designer: Mary Convertino respective owners. Cengage Learning disclaims any affiliation, association,
connection with, sponsorship, or endorsement by such owners.
Senior Content Manager: Maria Garguilo

Associate Digital Delivery Quality Partner: David For product information and technology assistance, contact us at
O’Connor Cengage Customer & Sales Support, 1-800-354-9706
or support.cengage.com.
Technical Editor: John Freitas
For permission to use material from this text or product, submit all
Developmental Editor: Dan Seiter
requests online at www.copyright.com.

VP, Product Marketing: Jason Sakos


Library of Congress Control Number: 2021925780
Director, Product Marketing: April Danaë
ISBN: 978-0-357-67342-3
Portfolio Marketing Manager: Mackenzie Paine
Cengage
IP Analyst: Ann Hoffman
200 Pier 4 Boulevard
IP Project Manager: Integra Software Services Boston, MA 02210
USA
Production Service: Straive
Cengage is a leading provider of customized learning solutions with
Senior Designer: Erin Griffin employees residing in nearly 40 different countries and sales in more than
125 countries around the world. Find your local representative at
Cover Image Source: iStock.com/gremlin
www.cengage.com.

To learn more about Cengage platforms and services, register or access


your online learning solution, or purchase materials for your course, visit
www.cengage.com.

Notice to the Reader


Publisher does not warrant or guarantee any of the products described herein or perform any independent analysis in connection with
any of the product information contained herein. Publisher does not assume, and expressly disclaims, any obligation to obtain and
include information other than that provided to it by the manufacturer. The reader is expressly warned to consider and adopt all safety
precautions that might be indicated by the activities described herein and to avoid all potential hazards. By following the instructions
contained herein, the reader willingly assumes all risks in connection with such instructions. The publisher makes no representations
or warranties of any kind, including but not limited to, the warranties of fitness for particular purpose or merchantability, nor are any
such representations implied with respect to the material set forth herein, and the publisher takes no responsibility with respect to
such material. The publisher shall not be liable for any special, consequential, or exemplary damages resulting, in whole or part, from
the readers’ use of, or reliance upon, this material.

Printed in the United States of America


Print Number: 01   Print Year: 2022

Copyright 2023 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
BRIEF CONTENTS
PREFACEXI

CHAPTER 1 Creating Java Programs�������������������������������������������������������������������������������� 1


CHAPTER 2 Using Data���������������������������������������������������������������������������������������������������� 39
CHAPTER 3 Using Methods�������������������������������������������������������������������������������������������� 83
CHAPTER 4 Using Classes and Objects����������������������������������������������������������������������� 115
CHAPTER 5 Making Decisions�������������������������������������������������������������������������������������� 161
CHAPTER 6 Looping������������������������������������������������������������������������������������������������������� 201
CHAPTER 7 Characters, Strings, and the StringBuilder�������������������������������������� 237
CHAPTER 8 Arrays��������������������������������������������������������������������������������������������������������� 267
CHAPTER 9 Inheritance and Interfaces����������������������������������������������������������������������� 329
CHAPTER 10 Exception Handling��������������������������������������������������������������������������������� 393
CHAPTER 11 File Input and Output����������������������������������������������������������������������������� 441
CHAPTER 12 Recursion������������������������������������������������������������������������������������������������� 487
CHAPTER 13 Collections and Generics����������������������������������������������������������������������� 511
CHAPTER 14 Introduction to Swing Components���������������������������������������������������� 545
APPENDIX A Working with the Java Platform ����������������������������������������������������������� 587

APPENDIX B Data Representation ����������������������������������������������������������������������������� 591

APPENDIX C Formatting Output �������������������������������������������������������������������������������� 595

APPENDIX D Generating Random Numbers ������������������������������������������������������������ 603

APPENDIX E Javadoc ���������������������������������������������������������������������������������������������������� 607

APPENDIX F Using JavaFX and Scene Builder ����������������������������������������������������������� 613

GLOSSARY 625
INDEX 641

iii

Copyright 2023 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
CONTENTS
PREFACEXI Key Terms 32
Review Questions 33
CHAPTER 1 Programming Exercises 34
Debugging Exercises 36
CREATING JAVA PROGRAMS 1
Game Zone 36
1.1 Learning Programming Terminology 1 Case Problems 37
1.2 Comparing Procedural and Object-
Oriented Programming Concepts 4
CHAPTER 2
Procedural Programming 4
Object-Oriented Programming 5 USING DATA 39
Understanding Classes, Objects, and Encapsulation 6
2.1 Declaring and Using Constants
Understanding Inheritance and Polymorphism 7
and Variables 39
1.3 Features of the Java Programming Declaring Variables 40
Language8
Declaring Named Constants 42
1.4 Analyzing a Java Application That The Scope of Variables and Constants 43
Produces Console Output 10
Concatenating Strings to Variables and
Understanding the Statement That Produces the Constants 43
Output10
Pitfall: Forgetting That a Variable Holds One
Understanding the First Class 12 Value at a Time 45
Understanding the main() Method 14
2.2 Learning About Integer Data
Indent Style 15
Types47
Saving a Java Class 16
2.3 Using the boolean Data Type 51
1.5 Compiling a Java Class and
Correcting Syntax Errors 18 2.4 Learning About Floating-Point
Compiling a Java Class 18 Data Types 52
Correcting Syntax Errors 19 2.5 Using the char Data Type 53
1.6 Running a Java Application and 2.6 Using the Scanner Class to
Correcting Logic Errors 23 Accept Keyboard Input 57
Running a Java Application 23 Pitfall: Using nextLine() Following One of the
Modifying a Compiled Java Class 23 Other Scanner Input Methods 59
Correcting Logic Errors 24
2.7 Using the JOptionPane Class to
1.7 Adding Comments to a Java Class 25 Accept GUI Input 64
1.8 Creating a Java Application That Using Input Dialog Boxes 64
Produces GUI Output 27 Using Confirm Dialog Boxes 66
1.9 Finding Help 29 2.8 Performing Arithmetic Using
Variables and Constants 68
Don’t Do It 30 Associativity and Precedence 69
Summary31 Writing Arithmetic Statements Efficiently 69

iv

Copyright 2023 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Contents v

Pitfall: Not Understanding Imprecision in Game Zone 113


Floating-Point Numbers 70 Case Problems 114
2.9 Understanding Type Conversion 72
Automatic Type Conversion 73 CHAPTER 4
Explicit Type Conversion 73
USING CLASSES AND OBJECTS 115
Don’t Do It 76 4.1 Learning About Classes
Summary 77 and Objects 115
Key Terms 77 4.2 Creating a Class 117
Review Questions 78
Programming Exercises 80
4.3 Creating Instance Methods
in a Class 119
Debugging Exercises 81
Game Zone 81 4.4 Declaring Objects and
Case Problems 82 Using Their Methods 124
Understanding Data Hiding 126

CHAPTER 3 4.5 Understanding That Classes


Are Data Types 128
USING METHODS 83 4.6 Creating and Using Constructors 131
3.1 Understanding Method Calls and Creating Constructors with Parameters 132
Placement83
4.7 Learning About the this
3.2 Understanding Method Reference134
Construction86 Using the this Reference to Make
Access Specifiers 86 Overloaded Constructors More Efficient 137
The static Modifier 87
4.8 Using static Fields 139
Return Type 87
Using Constant Fields 140
Method Name 87
Parentheses 88 4.9 Using Imported, Prewritten
Constants and Methods 143
3.3 Adding Parameters to Methods 91
The Math Class 144
Creating a Method That Receives a Single
Importing Classes That Are Not Imported
Parameter 91
Automatically 145
Creating a Method That Requires Multiple
Using the LocalDate Class 146
Parameters 94

3.4 Creating Methods That 4.10 U


 nderstanding Composition
Return Values 95 and Nested Classes 150
Composition 150
3.5 Understanding Blocks and Scope 99
Nested Classes 151
3.6 Overloading a Method 104
3.7 Learning about Ambiguity 107 Don’t Do It 153
Summary 153
Don’t Do It 108 Key Terms 154
Summary 108 Review Questions 154
Key Terms 109 Programming Exercises 156
Review Questions 109 Debugging Exercises 158
Programming Exercises 111 Game Zone 158
Debugging Exercises 113 Case Problems 159

Copyright 2023 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
vi Contents

CHAPTER 5 CHAPTER 6
MAKING DECISIONS 161 LOOPING201
5.1 Planning Decision-Making Logic 161 6.1 Learning About the Loop
5.2 The if and if…else Statements 163 Structure201
The if Statement 163 6.2 Creating while Loops 202
Pitfall: Misplacing a Semicolon in an if Statement 164 Writing a Definite while Loop 202
Pitfall: Using the Assignment Operator Instead Pitfall: Failing to Alter the Loop Control Variable
of the Equivalency Operator 165 Within the Loop Body 204
Pitfall: Attempting to Compare Objects Using Pitfall: Unintentionally Creating a Loop with
the Relational Operators 165 an Empty Body 204
The if…else Statement 166 Altering a Definite Loop’s Control Variable 206
Writing an Indefinite while Loop 206
5.3 Using Multiple Statements in
if and if…else Clauses 168 Validating Data 208

5.4 Nesting if and if…else 6.3 Using Shortcut Arithmetic


Statements172 Operators210
5.5 Using Logical AND and OR 6.4 Creating a for Loop 214
Operators174 Variations in for Loops 215
The AND Operator 174 6.5 Learning How and When to Use
The OR Operator 175 a do…while Loop 217
Short-Circuit Evaluation 175 6.6 Learning About Nested Loops 220
5.6 Making Accurate and Efficient 6.7 Improving Loop Performance 223
Decisions178 Avoiding Unnecessary Operations 223
Making Accurate Range Checks 178 Considering the Order of Evaluation of
Making Efficient Range Checks 180 Short-Circuit Operators 224
Using && and || Appropriately 180 Comparing to Zero 224
5.7 Using switch  181 Employing Loop Fusion 226
Using the switch Expression 183 A Final Note on Improving Loop Performance 226

5.8 Using the Conditional and NOT


Operators186 Don’t Do It 228
Summary 228
Using the NOT Operator 187
Key Terms 229
5.9 Understanding Operator
Review Questions 229
Precedence187
Programming Exercises 232
5.10 M
 aking Constructors More Debugging Exercises 233
Efficient by Using Decisions in
Game Zone 234
Other Methods 189
Case Problems 235

Don’t Do It 193


Summary 193 CHAPTER 7
Key Terms 194
CHARACTERS, STRINGS, AND
Review Questions 194
THE StringBuilder 237
Programming Exercises 197
Debugging Exercises 198 7.1 Understanding String Data
Game Zone 199
Problems237
Case Problems 200 7.2 Using Character Class Methods 238

Copyright 2023 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Contents vii

7.3 Declaring and Comparing 8.8 Using Two-Dimensional and Other


String Objects 241 Multidimensional Arrays 300
Comparing String Values 241 Passing a Two-Dimensional Array to a Method 302
Empty and null Strings 245 Using the length Field with a Two-Dimensional
Array303
7.4 Using a Variety of String
Methods246 Understanding Jagged Arrays 304
Using Other Multidimensional Arrays 304
Converting String Objects to Numbers 249

7.5 Learning About the StringBuilder 8.9 Using the Arrays Class 307
and StringBuffer Classes 253 8.10 Creating Enumerations 311

Don’t Do It 257 Don’t Do It 316


Summary 258 Summary 317
Key Terms 258 Key Terms 318
Review Questions 258 Review Questions 318
Programming Exercises 260 Programming Exercises 320
Debugging Exercises 262 Debugging Exercises 323
Game Zone 263 Game Zone 323
Case Problems 264 Case Problems 327

CHAPTER 8 CHAPTER 9
ARRAYS267 INHERITANCE AND INTERFACES 329
8.1 Declaring an Array 267 9.1 Learning About the Concept of
8.2 Initializing an Array 271 Inheritance329
Inheritance Terminology 331
8.3 Using Variable Subscripts with an
Array273 9.2 Extending Classes 332
Using the Enhanced for Loop 275 9.3 Overriding Superclass Methods 336
Using Part of an Array 275 Using the @Override Annotation 337
8.4 Declaring and Using Arrays 9.4 Calling Constructors During
of Objects 277 Inheritance339
Using the Enhanced for Loop with Objects 279 Using Superclass Constructors That Require
Manipulating Arrays of Strings 279 Arguments 340

8.5 Searching an Array and Using 9.5 Accessing Superclass Methods 344
Parallel Arrays 284 Comparing this and super 345
Using Parallel Arrays 284
9.6 Employing Information Hiding 346
Searching an Array for a Range Match 286
9.7 Methods You Cannot Override 348
8.6 Passing Arrays to and Returning
Arrays from Methods 289 A Subclass Cannot Override static Methods
in Its Superclass 348
Returning an Array from a Method 291
A Subclass Cannot Override final Methods
8.7 Sorting Array Elements 292 in Its Superclass 350
Using the Bubble Sort Algorithm 293 A Subclass Cannot Override Methods in a final
Improving Bubble Sort Efficiency 295 Superclass 351
Sorting Arrays of Objects 295 9.8 Creating and Using Abstract
Using the Insertion Sort Algorithm 296 Classes352

Copyright 2023 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
viii Contents

9.9 Using Dynamic Method Binding 359 10.7 T


 racing Exceptions Through the
Using a Superclass as a Method Parameter Type 360 Call Stack 415
9.10 C
 reating Arrays of Subclass 10.8 C
 reating Your Own Exception
Objects361 Classes419
9.11 U
 sing the Object Class and Its 10.9 Using Assertions 421
Methods364 10.10 Displaying the Virtual Keyboard 430
Using the toString() Method 364
Using the equals() Method 366 Don’t Do It 433
Overloading equals() 367 Summary 434
Overriding equals() 369 Key Terms 434
9.12 Creating and Using Interfaces 371 Review Questions 435
Creating Interfaces to Store Related Constants 374 Programming Exercises 437
Debugging Exercises 439
9.13 U
 sing records, Anonymous Inner
Classes, and Lambda Expressions 377 Game Zone 439

Using records 377 Case Problems 440

Using Anonymous Inner Classes 379


Using Lambda Expressions 380 CHAPTER 11
FILE INPUT AND OUTPUT 441
Don’t Do It 381
Summary 381
11.1 Understanding Computer Files 441
Key Terms 383 11.2 U
 sing the Path and Files
Review Questions 383 Classes443
Programming Exercises 385 Creating a Path 443
Debugging Exercises 389 Retrieving Information About a Path 444
Game Zone 390 Converting a Relative Path to an Absolute One 445
Case Problems 391 Checking File Accessibility 446
Deleting a Path 447
Determining File Attributes 448
CHAPTER 10
11.3 F
 ile Organization, Streams, and
EXCEPTION HANDLING 393 Buffers450
10.1 Learning About Exceptions 393 11.4 Using Java’s IO Classes 452
10.2 T
 rying Code and Catching Writing to a File 454
Exceptions397 Reading from a File 454
Using a try Block to Make Programs “Foolproof” 400 11.5 C
 reating and Using Sequential
Declaring and Initializing Variables in try…catch Data Files 457
Blocks 402
11.6 L
 earning About Random Access
10.3 T
 hrowing and Catching Multiple Files461
Exceptions404
11.7 W
 riting Records to a Random
10.4 Using the finally Block 408 Access Data File 463
10.5 U
 nderstanding the Advantages 11.8 R
 eading Records from a Random
of Exception Handling 410 Access Data File 468
10.6 S
 pecifying the Exceptions That Accessing a Random Access File Sequentially 468
a Method Can Throw 412 Accessing a Random Access File Randomly 470

Copyright 2023 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Contents ix

Don’t Do It 479 13.4 Using the LinkedList Class 524


Summary 479
13.5 Using Iterators 528
Key Terms 480
Review Questions 480
13.6 Creating Generic Classes 530
Programming Exercises 482 13.7 Creating Generic Methods 532
Debugging Exercises 484 Creating a Generic Method with More than One
Game Zone 484 Type Parameter 533

Case Problems 485


Don’t Do It 537

CHAPTER 12 Summary 538


Key Terms 538
RECURSION487 Review Questions 539

12.1 Understanding Recursion 487 Programming Exercises 541


Debugging Exercises 542
12.2 U
 sing Recursion to Solve
Game Zone 542
Mathematical Problems 489
Case Problems 543
Computing Sums 490
Computing Factorials 491
12.3 U
 sing Recursion to Manipulate CHAPTER 14
Strings495
INTRODUCTION TO Swing
Using Recursion to Separate a Phrase into Words 495
Using Recursion to Reverse the Characters in a
COMPONENTS545
String 496 14.1 U
 nderstanding Swing
12.4 U
 sing Recursion to Create Visual Components545
Patterns499 14.2 Using the JFrame Class 547
12.5 R
 ecursion’s Relationship to Customizing a JFrame’s Appearance 549
Iterative Programming 500 14.3 Using the JLabel Class 552
Changing a JLabel’s Font 553
Don’t Do It 503
14.4 Using a Layout Manager 555
Summary 503
Key Terms 504 14.5 Extending the JFrame Class 557
Review Questions 504 14.6 A
 dding JTextFields and
Programming Exercises 506 JButtons to a JFrame 559
Debugging Exercises 508 Adding JTextFields to a JFrame 559
Game Zone 509 Adding JButtons to a JFrame 560
Case Problems 510 14.7 L
 earning About Event-Driven
Programming563
CHAPTER 13 Preparing Your Class to Accept Event Messages 564
Telling Your Class to Expect Events to Happen 564
COLLECTIONS AND GENERICS 511 Telling Your Class How to Respond to Events 564
13.1 U
 nderstanding the Collection Writing an Event-Driven Program 565
Interface511 Using Multiple Event Sources 566
13.2 U
 nderstanding the List Using the setEnabled() Method 567
Interface513
14.8 U
 nderstanding Swing Event
13.3 Using the ArrayList Class 514 Listeners569

Copyright 2023 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
x Contents

14.9 U
 sing the JCheckBox, APPENDIX C
ButtonGroup, and JComboBox
Classes572 FORMATTING OUTPUT  595
The JCheckBox Class 572
The ButtonGroup Class 574 APPENDIX D
The JComboBox Class 575
GENERATING RANDOM
Don’t Do It 580 NUMBERS 603
Summary 581
Key Terms 581 APPENDIX E
Review Questions 582
JAVADOC  607
Programming Exercises 584
Debugging Exercises 585
Game Zone 585
APPENDIX F
Case Problems 586 USING JAVAFX AND SCENE
BUILDER613
APPENDIX A
GLOSSARY 625
WORKING WITH THE INDEX 641
JAVA PLATFORM 587

APPENDIX B
DATA REPRESENTATION 591

Copyright 2023 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
PREFACE
Java Programming, Tenth Edition provides the beginning programmer with a guide to developing applications
using the Java programming language. Java is popular among professional programmers because it is object-
oriented, making complex problems easier to solve than in some other languages. Java is used for desktop
computing, mobile computing, game development, Web development, and numerical computing.

This course assumes that you have little or no programming experience. It provides a solid background in
good object-oriented programming techniques and introduces terminology using clear, familiar language. The
programming examples are business examples; they do not assume a mathematical background beyond high
school business math. In addition, the examples illustrate only one or two major points; they do not contain so
many features that you become lost following irrelevant and extraneous details. Complete, working programs
appear frequently in each chapter; these examples help students make the transition from the theoretical
to the practical. The code presented in each chapter also can be downloaded from the Cengage website, so
students easily can run the programs and experiment with changes to them.

The student using Java Programming, Tenth Edition builds applications from the bottom up rather than
starting with existing objects. This facilitates a deeper understanding of the concepts used in object-oriented
programming and engenders appreciation for the existing objects students use as their knowledge of the
language advances. When students complete this course, they will know how to modify and create simple Java
programs, and they will have the tools to create more complex examples. They also will have a fundamental
knowledge of object-oriented programming, which will serve them well in advanced Java courses or in studying
other object-oriented languages such as C++, C#, and Visual Basic.

Organization and Coverage


Java Programming, Tenth Edition presents Java programming concepts, enforcing good style, logical thinking,
and the object-oriented paradigm. Objects are covered right from the beginning, earlier than in many other
Java courses. You create your first Java program in Chapter 1. Chapters 2, 3, and 4 increase your understanding
about how data, classes, objects, and methods interact in an object-oriented environment.

Chapters 5 and 6 explore input and repetition structures, which are the backbone of programming logic and
essential to creating useful programs in any language. You learn the special considerations of string and array
manipulation in Chapters 7 and 8.

Chapters 9 and 10 thoroughly cover inheritance, interfaces, and exception handling. Inheritance is the object-
oriented concept that allows you to develop new objects quickly by adapting the features of existing objects,
interfaces define common methods that must be implemented in all classes that use them, and exception
handling is the object-oriented approach to handling errors. All of these are important concepts in object-
oriented design. Chapter 11 provides information about handling files so you can store and retrieve program
output.

Chapter 12 explains recursion, and Chapter 13 covers Java collections and generics. Both are important
programming concepts, and Java provides excellent ways to implement and learn about them. Chapter 14
introduces GUI Swing components, which are used to create visually pleasing, user-friendly, interactive
applications.

xi

Copyright 2023 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xii Preface

New in This Edition


The following features are new for the Tenth Edition:

❯❯Java: All programs have been tested using Java 16.

❯❯Java help: Instructions on searching for Java help have been updated to avoid using specific URLs because new
Java versions are now being released twice a year.
❯❯Text blocks: Chapter 2 introduces text blocks—a new feature since Java 13.

❯❯Methods: Methods are covered thoroughly in Chapter 3, including topics such as overloading methods and
avoiding ambiguity. In previous editions, the material was split between chapters.
❯❯Classes and objects: Classes and objects are covered thoroughly in Chapter 4. In previous editions, the material
was split between chapters.
❯❯The switch expression: Chapter 5 includes the switch expression, which became a new feature in Java 14.

❯❯Arrays: Chapter 8 covers beginning and advanced array concepts. In previous editions, this content was split
between chapters.
❯❯Inheritance and interfaces: Chapter 9 covers inheritance and interfaces. In previous editions, this content was
split between chapters.
❯❯The record keyword: Chapter 9 also introduces the record keyword, which allows simple classes to be
developed more quickly because a constructor and methods to get and set fields are created automatically
based on field definitions.
❯❯Recursion: Chapter 12 is a new chapter on recursion. The chapter presents techniques to use to solve
mathematical problems, manipulate strings, and create visual patterns using recursion.
❯❯Collections and generics: Chapter 13 is a new chapter on collections and generics. The chapter covers the
Collection and List interfaces, the ArrayList and LinkedList classes, Iterators, and generic
classes and methods.

Additionally, Java Programming, Tenth Edition includes the following features:

❯❯Objectives: Each chapter begins with a list of objectives so you know the topics that will be presented in the
chapter. In addition to providing a quick reference to topics covered, this feature provides a useful study aid.
❯❯You Do It: In each chapter, step-by-step exercises help students create multiple working programs that
emphasize the logic a programmer uses in choosing statements to include. These sections provide a means for
students to achieve success on their own—even those in online or distance learning classes.
❯❯Notes: These highlighted tips provide additional information—for example, an alternative method of performing
a procedure, another term for a concept, background information about a technique, or a common error to
avoid.
❯❯Emphasis on student research: The student frequently is advised to use the Web to investigate Java classes,
methods, and techniques. Computer languages evolve, and programming professionals must understand how to
find the latest language improvements.
❯❯Figures: Each chapter contains many figures. Code figures are most frequently 25 lines or fewer, illustrating one
concept at a time. Frequent screenshots show exactly how program output appears. Callouts appear where
needed to emphasize a point.
❯❯Color: The code figures in each chapter contain all Java keywords in blue. This helps students identify keywords
more easily, distinguishing them from programmer-selected names.
❯❯Files: More than 200 student files can be downloaded from the Cengage website. Most files contain the code
presented in the figures in each chapter; students can run the code for themselves, view the output, and make

Copyright 2023 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface xiii

changes to the code to observe the effects. Other files include debugging exercises that help students improve
their programming skills.
❯❯Two Truths & a Lie: A short quiz reviews almost every chapter section, with answers provided. This quiz
contains three statements based on the preceding section of text—two statements are true, and one is false.
Over the years, students have requested answers to problems, but we have hesitated to distribute them in case
instructors want to use problems as assignments or test questions. These true-false quizzes provide students
with immediate feedback as they read, without “giving away” answers to the multiple-choice questions and
programming exercises.
❯❯Don’t Do It: This section at the end of each chapter summarizes common mistakes and pitfalls that plague new
programmers while learning the current topic.
❯❯Summary: Following each chapter is a summary that recaps the programming concepts and techniques covered
in the chapter. This feature provides a concise means for students to check their understanding of the main
points in each chapter.
❯❯Key Terms: Each chapter includes a list of newly introduced vocabulary, shown in alphabetical order. The list of
key terms provides a short review of the major concepts in the chapter.
❯❯Review Questions: Each chapter includes 20 multiple-choice questions that serve as a review of chapter topics.

❯❯Programming Exercises: Multiple programming exercises are included with each chapter. These challenge
students to create complete Java programs that solve real-world problems.
❯❯Debugging Exercises: Four debugging exercises are included with each chapter. These are programs that
contain logic or syntax errors that the student must correct. Besides providing practice in deciphering error
messages and thinking about correct logic, these exercises provide examples of complete and useful Java
programs after the errors are repaired.
❯❯Game Zone: Each chapter provides one or more exercises in which students can create interactive games
using the programming techniques learned up to that point; 50 game programs are suggested in the course.
The games are fun to create and play; writing them motivates students to master the necessary programming
techniques. Students might exchange completed game programs with each other, suggesting improvements and
discovering alternate ways to accomplish tasks.
❯❯Cases: Each chapter contains two running case problems. These cases represent projects that continue to
grow throughout a semester using concepts learned in each new chapter. Two cases allow instructors to assign
different cases in alternate semesters or to divide students in a class into two case teams.
❯❯Glossary: A glossary contains definitions for all key terms in the course.

❯❯Appendices: This edition includes useful appendices on working with the Java platform, data representation,
formatting output, generating random numbers, creating Javadoc comments, and JavaFX.
❯❯Quality: Every program example, exercise, and game solution was tested by the author and then tested again by
a quality assurance team.

MindTap Instructor Resources


MindTap activities for Java Programming, Tenth Edition are designed to help students master the skills they need in
today’s workforce. Research shows employers need critical thinkers, troubleshooters, and creative problem-solvers
to stay relevant in our fast-paced, technology-driven world. MindTap helps you achieve this with assignments and
activities that provide hands-on practice and real-life relevance. Students are guided through assignments that help
them master basic knowledge and understanding before moving on to more challenging problems.

All MindTap activities and assignments are tied to defined unit learning objectives. MindTap provides the analytics and
reporting so you can easily see where the class stands in terms of progress, engagement, and completion rates. Use

Copyright 2023 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Other documents randomly have
different content
an implied assurance that they reflect historical situations. When
Toynbee compares civilizations with motor cars on a one-way street,
[17]
or with men resting or climbing on a mountainside, he conveys
the impression (which he himself judges correct) that a definite
direction, a forward or upward movement, is discernible in history.
But such dynamics are imputed, not observed. He writes:

Primitive societies, as we know them by direct observation, may be


likened to people lying torpid upon a ledge on a mountainside, with
a precipice below and a precipice above; civilizations may be
likened to companions of these “sleepers of Ephesus” who have
just risen to their feet and have started to climb on up the face of
[18]
the cliff.

This image (further elaborated in the book, and duly illustrated with a
picture in Time magazine) does a great deal more than tell us that
primitive societies are static and civilizations dynamic. The
dominating feature of the image is the rock cliff with its succession of
ledges and precipices. Where is the historical reality 14
corresponding to this scenery which exists independent of the
sleepers and climbers and determines their direction? The “one-way
street” likewise suggests a predetermined orientation and limitation
of cultural endeavour. Toynbee believes that there is a cliff to be
climbed, a street to be followed. Yet the truth is—in the terms of his
images—that we see figures at rest or on the move in a cloudy space
but know nothing about their relative position: we do not know which
ledge is above or below which other ledge. Or again: we see motor
cars moving, halting, or out of order. But we do not know whether
they move in an alley, or on a four-drive highway, on an open plain,
or within a circle—we do not even know whether there is an entrance
or exit at all.

Toynbee’s images betray an evolutionistic as well as a moral bias


which interferes with the historian’s supreme duty of doing justice to
each civilization on its own terms. Why should we characterize
civilizations which have achieved a deep and lasting harmony (like
those of the Zuni or of certain Polynesians) as “arrested civilizations”
where “no energy is left over for reconnoitring the course of the road
ahead, or the face of the cliff above them, with a view to a further
[19]
advance”? Where is this road or this cliff? Why should these
chimaeras and a feverish desire for “advancement” disturb the
satisfaction of people who have attained the double integration of
individual and society and of society and nature? Toynbee merely
projects postulates which fulfil an emotional need in the West into
human groups whose values lie elsewhere. In our own terms:
Toynbee declares the “dynamism” of western civilization to be
universally valid; and he can do that only by ignoring the “form” of
non-western civilizations. But understanding is thereby precluded.

Toynbee is not the first historian to introduce the notion of 15


“progress” in his work, and the fallacy of this procedure has
[20]
been well demonstrated by Collingwood. Of his arguments we can
quote only two passages. He maintains that a historian comparing
two historical periods or ways of life must be able to “understand
(them) historically, that is with enough sympathy and insight to
reconstruct their experience for himself.” But that means that he has
already accepted them as things to be judged by their own
standards. Each is for the historian “a form of life having its own
problems, to be judged by its success in solving those problems and
no others. Nor is he assuming that the two different ways of life were
attempts to do one and the same thing and asking whether the
second did it better than the first. Bach was not trying to write like
Beethoven and failing; Athens was not a relatively unsuccessful
attempt to produce Rome.”

Collingwood then indicates the exceptional (and really purely


[21]
academic) case in which one may be entitled to speak of progress,
and in doing so touches upon a subject with which modern man is
particularly concerned:
Can we speak of progress in happiness or comfort or satisfaction?
Obviously not.... The problem of being comfortable in a 16
medieval cottage is so different from the problem of being
comfortable in a modern slum that there is no comparing them;
the happiness of a peasant is not contained in the happiness of a
millionaire.

Toynbee, though he is less precise than Collingwood, does formulate


what he means by progress. He equates it with growth, and “growth
[22]
is progress towards self-determination.” But Toynbee, who is a
believing Christian, surely knows that self-determination may not be a
matter of gradual advance at all, but rather a flash-like illumination in
which one’s true nature stands revealed. As a rule, the sequel to this
experience is a life-long struggle for a realization of the vision. Why
could not this type of self-determination also, like the slow and
gradual realization, have an analogy in the life of civilizations?
Flinders Petrie and others have maintained that every significant trait
of Egyptian culture had been evolved before the end of the Third
Dynasty. We find once more that Toynbee has uncritically proclaimed
the universal validity of one of several possible sequences. And if he
describes “the consummation of human history” as “accomplishing
[23]
the transformation of Sub-Man through Man into Super-Man” and
calls this “the goal towards which ‘the whole creation groaneth and
[24]
travaileth’ (Romans viii, 22),” we may respect his faith but can
hardly accept it as the argument of an “empirical student of
[25]
history.”

It is, in fact, odd that Toynbee, who opens his work with an excellent
statement of the relativity of historical thought, who complains that
“a local and temporary standpoint has given our historians a false
perspective,” remains himself so completely under the spell of a 17
nineteenth-century western outlook. His evolutionary bias, his
empiricism, and his treatment of civilizations as “specimens of a
species” are all of a piece. He sometimes equals Spengler in myth-
making, treating his equation of civilizations and living beings as a
reality, and appealing to biological opinion to uphold a historical
[26]
conclusion. His use of “species” and “genus” obscures the
fundamental fact that science can study individuals as members of a
species only by ignoring their individual characteristics. The historian,
following this course, would defeat the very purpose of his work.

In fact, Toynbee’s vaunted empiricism is an attempt to transpose the


method of the natural sciences, where experiment is essential and
experience is reduced to figures, to history, where experiment is
impossible and experience subjective. Toynbee’s “experience” (a word
which, in the case of a historian, may stand for intimate acquaintance
with historical data) is confined to classical antiquity and its western
descendant. It is an odd fact that he should have supposed this
limited field capable of supplying the conceptual apparatus with
which every historical phenomenon could be comprehended, and that
he should have done this, not unconsciously, but knowingly, 18
although unaware of the enormity of his assumption. For
anyone moving outside western tradition should soon discover the
truth that the values found in different civilizations are
incommensurate. And so we find Toynbee, like Spengler, doing
violence to the evidence and forcing each civilization into a
preconceived system of categories. In his case the system is not, like
Spengler’s, an imaginative construction; but it is derived from the
crucial period in western history when the Roman Empire
disintegrated. His generalization of particular circumstances results
not in historical errors but in irrelevancies. It would be a tedious and
laborious task to demonstrate this to the full; but let us take two
characteristic quotations referring to Egypt.

Toynbee expects to find in every civilization an analogy of the early


Christian Church in the Roman Empire, and thus postulates for Egypt
an “Osireian Church” as a “universal church created by an internal
[27]
proletariat.” Now, a “church” as an organized body of believers
was not known in Egypt at any time (nor in Mesopotamia, for that
matter). The worship of Osiris, always a main concern of the king,
spread through all classes of the population, but merely as one
among many devotions which filled the life of every Egyptian; the
god was never honoured by one group more than by another. And, in
fact, no section of the population of Egypt can be called a proletariat
if this word is to remain applicable to imperial Rome or to modern
[28]
times. If, elsewhere, Toynbee describes the expulsion of the
Hyksos invaders from Egypt as due to a “union sacrée between the
dominant minority of the Egyptiac society and its internal proletariat
against the external proletariat as represented by the Hyksos” 19
one can only say that the words, severally and in conjunction,
do not apply. But he continues:

for it was this reconciliation at the eleventh hour that prolonged


the existence of the Egyptiac society—in a petrified state of life-in-
death—for two thousand years beyond the date when the progress
of disintegration would otherwise have reached its natural term in
dissolution. And this life-in-death was not merely an unprofitable
burden to the moribund Egyptiac society itself; it was also a fatal
blight upon the growth of the living Osireian church ... for this
union sacrée ... took the form of an amalgamation of the living
worship of Osiris with the dead worship of the official Egyptiac
pantheon.

Reading this, one would not suspect that the five centuries following
the expulsion of the Hyksos are the most brilliant epoch of Egyptian
history. One would also not assume that after about one thousand
years of this “life-in-death,” religious texts glorifying Amon-Re were
written which in profundity of thought and literary splendour belong
to the greatest in Egyptian literature, and are its nearest approach to
[29]
the majestic monotheism of the Old Testament. Surely an
“empirical” approach would have started from the fact that Egyptian
civilization did actually retain its vitality over an unusually long period.
Toynbee, however, declares that the Egyptian achievements in the
second and first millennia B.C. are but illusions, for the scheme to
which he is committed (although it is alien, and hence irrelevant, to
Egyptian history) requires a “time of troubles” before the Middle
[30]
Kingdom which must be followed by a “universal church” 20
with its two types of proletariat. Thus the confessed
“empiricist” adheres to a preconceived system and disposes of the
facts by proclaiming the Hyksos period “a date when the process of
disintegration would otherwise have reached its natural term in
dissolution.” (The italics are mine.)

The scheme which we have criticized in its application to Egypt is


intended to render account of the dynamics of civilizations in their
last phases. For the early phases, the classical world cannot supply
ready-made notions. Here Toynbee introduces a set of formulas
which may be summarized in his own words:

Growth is achieved, when an individual, or a minority, or a whole


society, replies to a challenge by a response, which not only
answers the particular challenge that has evoked it, but also
exposes the respondent to a fresh challenge which demands a
fresh response on his part. And the process of growth continues, in
any given case, so long as this recurrent movement of disturbance
and restoration and overbalance and renewed disturbance of
[31]
equilibrium is maintained.

But communities react differently under a common challenge; some


are apt

to succumb whereas others strike out a successful response


through a creative movement of Withdrawal-and-Return, while
others again, neither succeed in responding along original lines nor
fail to respond altogether, but manage to survive the crisis by
waiting until some creative individual or creative minority has
shown the way through, and then following tamely in the footsteps
of the pioneers.
These plausible words do not, upon closer inspection, explain 21
the problem which concerns us. The “creative movement of
Withdrawal-and-Return” is illustrated by examples which rob it not
[32]
only of its obvious, but of all definite, meaning.
[33]
The other formula—that of “Challenge-and-Response” —is not
evolved from inside history either but is applied, as it were, from the
outside; and its applicability, let alone its power to explain the facts,
is often more than doubtful. “Challenge-and-Response” is sometimes
used to describe a true conflict; sometimes it refers merely to the
ordinary seesaw of historical fortune. Always, however, it has a 22
misleading ring, since observed facts are called a response, to
a hypothetical challenge construed to meet those facts. In Volume II,
“The Range of Challenge-and-Response,” we find headings like “The
Stimulus of Hard Countries,” “The Stimulus of New Ground,” “The
Stimulus of Blows,” “The Stimulus of Pressure,” “The Stimulus of
Penalization,” and so on. The primary data of history merely show
that certain peoples achieved greatness; Toynbee thinks that the
adverse conditions which he enumerates served as stimuli. That may
be so. In any case, it does not explain the fact which, above all
others, requires explanation, namely, that in some cases these
conditions worked as stimuli and in others they did not. I do not find,
therefore, that the formula is conducive to understanding; it must in
each case invent a challenge to fit a historical reality which it labels
response.

Our criticism does not proceed from a positivistic belief in a so-called


“scientific” historiography which is supposed first to assemble
objective facts which are subsequently interpreted. Our objection
here is not against Toynbee’s procedure, but against a terminology
which obscures what is the starting-point, and what the outcome, of
his procedure. And we make the further criticism that he does not
actually evolve from each particular historical situation the notion of a
particular challenge to which it can be construed as a response; he
applies the formula, as I have said, from the outside, and it is
therefore doomed to irrelevance. For example: Toynbee considers the
descent of the prehistoric Egyptians into the marshy Nile valley as
their response to the challenge of the desiccation of North Africa. In
their new homeland they faced, in due course, as a further challenge,
“the internal articulation of the new-born Egyptiac society” and failed.
The truth is that the Egyptians flourished exceedingly for two 23
thousand years after the Pyramid Age; but Toynbee thinks they
failed because he cannot conceive of a “response” in Egyptian terms,
but only in those with which he is familiar: secular government,
[34]
democracy, and the Poor Law. But since neither the rich nor the
poor Egyptians took this view of their state, Toynbee’s conclusion is
irrelevant. It is true that he quotes the tales which dragomans told to
late Greek travellers about the oppressive rule of the builders of the
pyramids. But the actual folk-tales of Pharaonic Egypt show us that
the people took as great a delight in tales of royalty as the public of
the Arabian Nights took in the doings of the despot Harun al Rashid.
Snefru, whom Toynbee names, is known as one of the most popular
rulers in legend. The fact of the matter is that Toynbee should have
started from an analysis of the “response.” This would not have
shown, as Toynbee has it, that “Death laid its icy hand on the life of
the growing civilization at the moment when the challenge that was
the stimulus of its growth was transferred from the external to the
internal field [from the subjugation of nature to the organization of
society, H.F.] because in this new situation, the shepherds of the
[35]
people betrayed their trust.” Studied without preconceived ideas
the “response” of the Egyptians stands revealed as a vastly different
achievement. The ideal of a marvellously integrated society had been
formed long before the pyramids were built; it was as nearly realized,
when they were built, as any ideal social form can be translated into
actuality; and it remained continuously before the eyes of rulers and
people alike during subsequent centuries. It was an ideal which ought
to thrill a western historian by its novelty, for it falls entirely 24
outside the experience of Greek or Roman or Modern Man,
although it survives, in an attenuated form, in Africa. It represents a
harmony between man and the divine which is beyond our boldest
dreams, since it was maintained by divine power which had taken
charge of the affairs of man in the person of Pharaoh. Society moved
in unison with nature. Justice, which was the social aspect of the
cosmic order, pervaded the commonwealth. The “trust” which the
people put in their “shepherds” was by no means what Toynbee
imagines; their trust was that Pharaoh should wield to the full the
absolute power to which his divinity entitled him, and which enabled
him—as nothing else could—to ensure the well-being of the whole
community.

It seems to me that these discussions have cleared the ground for


our understanding. Generalizations based on a limited historical
experience, and theorizing, however ingeniously conducted, must fail
to disclose the individual character of any one civilization or of any
one series of events. We must concentrate on what Ruth Benedict
called the “selected segment of the arc of possible human behaviour,”
“the characteristic purposes not necessarily shared by other types of
society.” In our own terms: In studying the birth of a civilization we
are concerned with the emergence of its “form.”

25
II. THE PREHISTORY OF THE ANCIENT NEAR
EAST
At the end of our last chapter we said that the study of the birth of a
civilization means watching the emergence of its “form.” We have
also seen that this “form” is elusive, that it is not a concrete mould,
or a standard which we can apply to our observations to see whether
they conform with it. We have described it as “a certain consistency
in orientation, a cultural style.” Recognizing it amounts to discovering
a point of view from where seemingly unrelated facts acquire
coherence and meaning. Even so the “form” of a civilization remains
intangible; it is implicit in the preoccupations and valuations of the
people. It imparts to their achievements—to their arts and
institutions, their literature, their theology—something distinct and
final, something which has its own peculiar perfection. Therefore a
discussion of the emergence of form entails a knowledge of a
civilization in its maturity, a familiarity with its classical expression in
every field. Then it should be possible to work backwards from
better-known to early times until the point is reached where the
familiar phenomena are lost sight of and where, conversely, their
[36]
emergence must be postulated.

This procedure, however, has a double disadvantage. It 26


obscures development because it moves against the current of
time; and it fails to describe, first of all, the conditions under which
the civilization took shape—in other words, its prehistoric
antecedents. Now I am not prepared to attempt a definition of the
distinction between prehistory and history in general terms, for even
[37]
within the ancient Near East the distinction is problematical. I shall
simply use the term “prehistory” to denote the period preceding the
emergence of Egyptian and Mesopotamian civilization, and shall
discuss first the climatic conditions in the Near East at that time and
then the form of society which prevailed before the events with which
we are primarily concerned took place.

At present the arable lands of Egypt and Western Asia are embedded
in large tracts of desert. But it seems that in the Ice Age the pressure
of cold air over Europe compelled the Atlantic rain storms to travel
east by a more southerly track so that the whole area from the west
coast of Africa to the Persian mountains was a continuous belt of
park and grassland. In Algeria and southern Tripolitania hunters of
the Old Stone Age engraved images of elephants, buffaloes, 27
and giraffes on rocks now surrounded for hundreds of miles by
an arid waste where life is utterly impossible. Paleolithic implements
have been found on the high desert which flanks the Nile valley, and
in Syria, Palestine, and Kurdistan. Carved tools found in Palestine
(Fig. 1, A, B) and the engravings from North Africa find close parallels
in the splendid engravings and paintings from the caves of southern
France and northern Spain.

We want to dwell for a moment on the paleolithic remains in order to


insist that even these distant hunters cannot be understood as “part
[38]
of nature.” From paleolithic times onwards, man has been aware
of being involved, not only with his kindred, but with superhuman
powers. This dual involvement becomes apparent as soon as we find
more than the mere bones and implements of man. In France and
Spain hunters of the Old Stone Age left us astonishing paintings and
engravings depicting the game upon which they were dependent.
These works of art are found in the remote depths of caves and could
only be reached at mortal risk. Analogies found among modern
people still living in the Stone Age allow us to see in the marvellous
images of the beasts, the traces of dancing feet on the soil of the
caves, the stones marked with linear signs, the figures of masked or
dancing men, expressions of a coherent religious conception,
proclaiming man’s intimate and reciprocal relationship with the
animals, and beyond these, with the divine. Such a brief formula is,
[39]
of course, ludicrously inadequate; for one thing it 28
substitutes articulate concepts for unreflected experience. But we
formulate it in order to emphasize that, from the first, man possessed
creative imagination, and we have to reckon with this in considering
social cohesion. If the earliest men of whom we have knowledge co-
operated in order to trap and kill animals far more powerful than
themselves, their hunting differed toto cælo from the hunting of a
pack of wolves. Their art proves that their relation with their game
was not a mere matter of killing and devouring, and that their parties
were kept together, not merely by common need, but also by
imaginative, religious conceptions, made explicit, not in doctrine, but
in acts.

The transition from paleolithic to neolithic culture is not yet known;


but we do know that a change of climate, which started in the Old
Stone Age, continued in the New, and very gradually changed living
conditions throughout the Near East. Libya remained rich in
vineyards, olive trees, and cattle up to the end of the second
millennium B.C.—a fact which may be surmised from records of booty
[40]
brought back from there: by a Pharaoh of the First Dynasty; by
Sahure of the Fifth Dynasty (about 2475 B.C.), who listed 100,000
head of cattle and more than 200,000 each of asses, goats, and
[41]
sheep; and finally by Ramses III (about 1175 B.C.), who was still
able to take away 3600 head of cattle, in addition to horses, asses,
[42]
sheep, and goats. At the opposite end of the Near East, in south-
eastern Iran, Sir Aurel Stein was unable to round up a “minimum of
local labour” to investigate the thickly dotted ruins of ancient 29
[43]
settlements. Nevertheless, progressive desiccation marked
the period from perhaps 7000 B.C. onwards, turning the plateaux
from grassland into steppe and, ultimately, into desert, and making
the valleys of the great rivers inhabitable. When meadows and shrub
lands began to emerge from the swamps and mudflats along the
river courses, man descended from the highlands.
Now the earliest inhabitants of the valleys were in possession of a
considerable body of knowledge which the hunters of the Ice Age
had lacked. And we do not know how the change from old to new,
from the Old Stone Age to the New Stone Age, came about; for
nowhere has a series of continuous remains covering the transition
been recognized. I use this word advisedly, for we shall see in a
moment that the change was of such a nature that its earliest
consequences may well defy recognition. We know, however, that this
change, like the later one with which we are more especially
[44]
concerned, took place in the Near East.

The outstanding new feature of the neolithic age is agriculture, with


emmer wheat (Triticum dicoccum) and six-rowed barley (Hordeum
hexastichum) as the main crops. Now the wild ancestors of these
grains survive even to-day in Syria and Palestine. In the same region,
in caves on Mount Carmel, were discovered remains of the earliest
[45]
men who used sickles. This does not prove, of course, that they
cultivated grain; they may merely have harvested grasses which grew
wild. The point is of importance since these people—known in
archaeological literature as Natufians—belong to the very end 30
of the Old Stone Age. Yet the Natufians were the initiators, or
at least the early practitioners, of a technique of harvesting which
survived in the earliest agricultural settlements of neolithic times.
Their peculiar sickles consisted of a grooved haft of bone in which
[46]
short pieces of flint—“teeth”—were mounted (Fig. 1 A, B). Such
sickles are also found in the oldest settlements in the Fayum (in
[47] [48]
Egypt) (Fig. 1 D), at Hassuna in northern Iraq, and at Sialk
[49]
near Kashan in Persia (Fig. 1 C). They date perhaps about 5000
B.C., possibly a thousand years or more after the Natufians. In Egypt,
during the First Dynasty (about 3100 B.C.), the sickle-haft was
improved by being curved; it was now made of wood but retained its
[50]
cutting edge of small flints (Fig. 1 E), and sickles of this type were
[51]
used as late as the Twelfth Dynasty (about 2000 B.C.). In Iraq,
too, sickles with curved wooden handles in which flint teeth were set
were used as late as the Second Early Dynasty period, about 2700
[52]
B.C. In Asia Minor and Europe no trace of the hafts has survived,
but the distinctive flint teeth have been found in Anatolia, South
Russia, on the Danube, and at the western end of the 31
Mediterranean at Almeria. They occur also throughout North
Africa. It is clear, then, that the diffusion of agriculture consisted not
merely in spreading the knowledge of emmer and barley but in a
simultaneous diffusion of the odd and complex harvesting tool, first
used, as far as we know, by the Natufians. Radiating from the Near
East, the new knowledge spread in widening circles, reaching the
[53]
shores of the Baltic and the North Sea about 2500 B.C. However,
many questions remain at present unanswered. When did men
undertake to improve the wild grasses and to produce, by cross-
breeding and selection, the vastly more nutritious grains which were
known to the earliest farmers of the neolithic period? When, in fact,
was the extraordinary first step taken and the satisfaction of
immediate needs limited in order to save seeds, store them,
safeguard them against insects and rodents, and sow them when the
time was propitious? This may have been done by the Natufians, but
of this we know nothing. Furthermore, we do not know how far
agricultural methods had advanced when they began to be diffused
throughout the Old World. In particular we know nothing about the
origin of irrigation, which played so large a part in Egypt and
Mesopotamia, and which has been repeatedly recognized as a factor
greatly furthering social and political cohesion, since it makes each
settlement dependent on its neighbours. We must, therefore,
consider this invention.

It deserves notice that irrigation can be resorted to by people who do


not cultivate but collect wild-growing plants. This is done, for
instance, by certain Indians of the Great Basin of Western North
[54]
America, and their methods could very well have been 32
followed by the Natufians utilizing the wadi running at the foot of
their cliffs. We may admit, then, that irrigation could have been one
of the features of the original agricultural complex which spread from
the Near East; but there are serious arguments to the contrary.

In the first place, the spread of agriculture seems to have been


achieved by means of a slow migration of the cultivators. Primitive
hoe or garden cultivation (which is still practised) exhausts the soil it
uses. It ignores rotation of crops or fallowing; after some years a
fresh piece of ground must be cleared and sown. When the
neighbourhood has been farmed, the village moves farther into the
bush. The smallness of the neolithic settlements and of their
[55]
cemeteries, and the manner in which they spread into the
European continent, suggests this type of slow but continual
migration outwards from the centre where agriculture was first 33
practised. There is no dependence on irrigation to be observed
here.

In the second place, there are African parallels which suggest that
the earliest agriculture in the Nile valley and Mesopotamia could also
have proceeded without irrigation. The conditions in these river
valleys in antiquity resembled closely those found nowadays on the
Blue Nile, where semi-Hamitic nomads, the Hadendoa, sow and
harvest in the simple manner which we shall now describe. It is
possible, therefore, to postulate similar simple methods for the
prehistoric Egyptians. Burckhardt renders his observations in the Taka
country of Nubia as follows:

About the latter end of June ... large torrents coming from the
South and South-east pour over the country and in the space of a
few weeks cover the whole surface with a sheet of water, varying
in depth from two to three feet.... The waters, on subsiding, leave
a thick slime, or mud, upon the surface, similar to that left by the
Nile.... Immediately after the inundation is imbibed, the Beduins
sow the seed upon the alluvial mud, without any previous
preparation whatever. The inundation is usually accompanied by
heavy downpours. The rains last several weeks longer than the
inundation but they are not incessant, falling in heavy showers at
short intervals.

The people appear to be ignorant of tillage. They have no regular


fields; and the Dhourra, their only grain, is sown among the thorny
trees and tents, by dibbling large holes in the ground, into each of
which a handful of the seed is thrown. After the harvest is
gathered, the peasants return to their pastoral occupations; they
seem never to have thought of irrigating the ground for a second
crop with the water which might everywhere be found by digging
wells. Not less than four-fifths of the ground remains unsown; but
as the quantity of Dhourra produced is generally sufficient ... they
never think of making any provisions for increasing it,
notwithstanding that, when the inundation is not copious, or 34
only partial (no one remembers it ever failing entirely) they
[56]
suffer all the misery of want.

This kind of procedure could not, of course, have been invented in


Palestine and Syria where rivers with regularly recurring inundations
are unknown. However, the same results can be achieved where
there are copious spring rains. Newberry says of the Alabdeh
(Hamites living between the Nile valley and the Red Sea): “Some of
these nomads sow a little barley or millet after a rainstorm, and then
pitch their tents for a while till the grain grows, ripens and can be
[57]
gathered. Then they move on again with their little flocks.”

There are, then, many ways in which a temporary abundance of


water can be utilized by simple people to produce crops, and it may
well be that the systematic distribution of water which marks the
agriculture of historical times in Egypt and Mesopotamia did not exist
in prehistoric times at all. We shall see that the problem of drainage
was at first as important as that of irrigation, or rather more so; in
this respect the modern analogies do not hold good.
The uncertainty attached to the earliest phases of agriculture makes
it impossible to speculate on the immediate social consequences of
the invention of food production. One would expect these to consist
in a greater emphasis on local rather than tribal groupings, a
limitation of outlook and horizon, a progressive differentiation of
separate settlements as a result of their attachment to the soil. But
the introduction of agriculture probably did not mean the more or
less speedy transition to a fully settled life or to a socio-political 35
[58]
organization on a large scale. Nor did it mean that all the
other ways of finding sustenance were neglected. A “partial
[59]
exploitation of the environment” is characteristic of modern
savages who have become stuck in a backwater, but not of the true
primitives of antiquity. The Natufians may have sown a catch crop or
gathered wild grasses, but they also hunted deer and speared fish.
All the early settlements of the Near East show signs of a many-sided
economy, although in all of them agriculture played an important
part. In all of them, too, we find stock-breeding; and this is an
innovation which we must simply take for granted since its origin and
[60]
motivation is at present quite obscure. The Natufians did not
possess domestic animals.

Other inventions, too, were known throughout the Near East in the
earliest settlements of the New Stone Age. Pottery-making is one of
them, weaving another. It is hardly to be wondered that we cannot
follow the first phases of their existence. If the earliest pots, for
instance, were only dried in the sun or lightly baked or were merely
clay-lined baskets, they cannot be expected to have survived. And it
may be considered exceptionally fortunate that of early textiles 36
[61]
a few scraps have survived for six or seven thousand years.
It is likewise only due to the refinements of modern excavation
technique that the oldest of the successive settlements of Hassuna,
near Mosul (Fig. 2), was recognized as a camp site, consisting of no
more than a number of hearths, still containing wood ashes. They
were made of “potsherds and pebbles set in a kind of primitive
[62]
cement” with pottery lying around them. Only in higher levels did
adobe walls appear. This single instance in which a very early
[63]
settlement was recognized explains why others remain unknown.
But we know that after (or during) the time of the Natufians these
important discoveries were made and diffused among villages
stretching from the Nile valley through the Delta and thence in a
great arch (Fig. 51) from Jericho in the south, via Byblos and Ras
Shamra on the Syrian coast to Mersin in Cilicia; then, through the
Amuq plain, east of Antioch, via Carchemish on the Euphrates to Tell
Halaf and Chagar Bazar in North Syria to Nineveh and Hassuna near
Mosul, and on eastwards, to Sialk near Kashan in central Persia.

Throughout this region we find small self-contained and self-


supporting settlements. Some beads, shells, or other luxuries 37
may have been imported from more or less distant regions by
means of hand-to-hand barter. Occasionally a rare raw material, such
as obsidian—volcanic glass, flaked and used, like flint, for tools—was
obtained regularly from outside. For the rest, one gets an impression
of a somewhat stagnant prosperity in which the great new inventions
were thoroughly exploited but little changed from generation to
generation for a very long time. There are differences in the crafts:
flint tools, pot designs (even ceramic techniques), and personal
ornaments differ from region to region and even, as in prehistoric
Thessaly, from village to village. There are also changes in style in
the course of time. But these local and temporal differences must not
detain us as we survey the prehistory of the ancient Near East with a
view to the subsequent development. For that purpose we can divide
the region into three parts: the two great river valleys and the area
between, in which the rich plains of North Syria were the most
important part. This central area was prosperous, but it remained
unprogressive until the second millennium, dependent on the great
cultural centres in Egypt and Mesopotamia. For that reason, we shall
confine our attention to the river valleys.
Modern Egypt, even if we disregard the aridity of its climate, differs
entirely from the land with which we are here concerned. Nowadays
the whole of the country is so intensively cultivated that it does not
possess sufficient grazing for its cattle, and one sees cows, buffaloes
and asses tethered at the desert edge and fed on cultivated crops
such as clover. The river is thoroughly controlled. The desert valleys—
wadis—are devoid of vegetation except for bushes of camel-thorn.
But in prehistoric, as well as in Pharaonic times, Egypt was a land of
marshes in which papyrus, sedge, and rushes grew to more 38
than man’s height (Fig. 3). The wadis, too, teemed with life;
they are best described as park land where as late as the New
Kingdom (1400 B.C.) man could hunt Barbary sheep, wild oxen, and
asses, and a wide variety of antelopes with their attendant
[64]
carnivores. It has been pointed out that the methods of hunting
prove that different types of landscape could be found here.
Sometimes rows of beaters are shown driving the game towards the
hunter or into nets, a method possible only in areas which are
somewhat thickly wooded. At other times lassos are used, which
presuppose pampa-like open spaces with low shrub.

In the valley, the annual flood of the Nile continuously changed the
lay of the land. When the water overflowed the river banks the silt,
previously kept in suspension by the speed of the swollen current,
precipitated. Some of this precipitation raised the river bed, the
remainder covered the banks and the area closest to them; towards
the edges of the valley there was comparatively little deposit. Thus
banks of considerable height were formed, and after some years the
weight of water broke through these natural dikes to seek a new
course in low-lying parts, some distance away. The old bed turned
into swamp, but its banks remained as ridges and hillocks whose
height and area were increased by wind-blown dust and silt caught at
their edges. Trees took root, and man settled there, sowing his crops
and grazing his beasts in the adjoining lowlands, to retire with them
to the high ground of the old banks when the river overflowed.
During the inundation, fish, wild boar, hippopotamus, and huge flocks
of water birds invaded the surrounding fields and supplied an
abundance of food throughout the summer.

All traces of these settlements in the valley proper have long 39


since disappeared; they have been not merely silted over but
[65]
washed away by the changes in the river’s course. This explains
why we find traces of early settlements only at the edge of the valley,
on the spurs of detritus at the foot of the high cliffs. We must
imagine the valley, not flat and featureless as it is to-day, but dotted
with hamlets perched on the high banks of former watercourses and
surrounded by an ever-changing maze of channels, marsh, and
meadow. Even as late as the First Intermediate period, just before
2000 B.C., the populace of a province in Middle Egypt left their homes
and hid in swamps in the valley to escape the dangers of civil war
[66]
and marauding soldiers. And the early predynastic settlements at
the valley’s edge were built in groves; among the remains of huts and
[67]
shelters, tree roots of considerable size have been found.

The prehistoric, “predynastic,” period of Egypt clearly falls into two


parts or stages (Fig. 4). The earliest of these is known in three
[68]
successive phases called Tasian, Badarian, and Amratian, each a
modified development of its predecessor. Together they represent the
African substratum of Pharaonic civilization, the material counterpart
of the affinities between ancient Egyptian and modern Hamitic
languages; of the physical resemblances between the ancient 40
Egyptians and the modern Hamites; and of the remarkable
similarities in mentality between these two groups which make it
possible to understand ancient Egyptian customs and beliefs by
[69]
reference to modern Hamitic analogies. The second stage of
[70]
predynastic culture—called Gerzean —is in many ways a
continuation of Amratian; in other words, the preponderantly African
character remained. But new elements were added, and these point
to fairly close relations with the East, with Sinai, and with Palestine.
Foreign pottery was imported from that quarter. A new type of
Egyptian pottery, implying a change in ceramic technique, was
derived from a class of wavy-handled vases which were at home in
Palestine. Several new kinds of stone used for vases may have come
[71]
from Sinai, and the increase in the use of copper points certainly
to closer relations with that peninsula. Although flint remained in use
and flint-work achieved an unrivalled beauty and refinement, 41
copper was no longer an odd substance used for luxuries but
appeared in the form of highly practical objects: harpoons, daggers,
[72]
axes (one of which weighs 3½ pounds). The language of the
[73]
country may also have been affected.

The innovations of Gerzean can best be explained as the effect of a


permeation of Upper Egypt by people who had affinities with their
Asiatic neighbours and derived from them certain features of their
[74]
culture. We know that in historical times a similar gradual but
continuous drift of people from Lower Egypt into Upper Egypt can be
[75]
observed. During the Gerzean period the country seems to have
become more densely populated; and it has been suggested that the
[76]
reclamation of the marshland was begun. Such work presupposes
co-operation between neighbouring groups and organization of 42
men in some numbers. We may assume that this took place,
but on a strictly limited scale. For there are no signs of large political
units. There are no ruins of great size, no monuments of an
exceptional nature; and if it is objected that these may have existed
but may not have been discovered yet, we must insist on the
significant fact that among the many thousands of predynastic graves
which have been found, there is not a single one which by its size or
[77]
equipment suggests the burial of a great chief. The Gerzean
innovation did not change the general character of the country’s
culture; the remains suggest a prosperous homogeneous population,
fully exploiting its rich environment and loosely organized in villages
and rural districts. It was in this setting that the efflorescence of
Pharaonic civilization occurred.

In Mesopotamia the corresponding change took place in the extreme


south, in the marshy plain between the head of the Persian Gulf and
[78]
the higher ground which stretches north from Samarra and Hit.
This older diluvial part of the country had been farmed already for
many centuries before the south was inhabited. The northern farmers
had passed through three phases which can be distinguished by their
[79]
material equipment (see chronological table at end of book). 43
When the third was predominant in the north, men from the
Persian plateau entered the southern marshes. Under present
conditions it would be inconceivable that highlanders would elect to
do so, or even that they would be able to survive there. But in the
fifth and fourth millennia B.C. the Iranian plateau had not yet become
a salt desert. Many rivers, descending from the surrounding
mountains, ended in upland seas without an outlet and ringed by
swamps. Even to-day, in eastern Iran, marsh dwellers are found on
[80]
the shores of the great lake of the river Hamun. Like the Marsh
Arabs of southern Iraq, they build boats and huts of reeds, fish and
keep water buffaloes and cattle. Similar conditions must have
prevailed over much of Persia in the period we are discussing, and
immigrants from such regions would be well prepared to face life in
the delta of the Euphrates and Tigris.

The pottery made by the earliest settlers of South Mesopotamia


shows that they came from Persia. At first they retained the tightly
[81]
interwoven geometric designs used in their homeland; but left to
themselves they soon adopted an easier flowing, careless 44
decoration (called Al Ubaid) which remained in use for many
centuries and represents the Persian tradition in only a very debased
form. In many places it is found on virgin soil, which shows that the
settlers spread farther through the country of which they had at first
occupied only certain localities. At Ur, for instance, detailed
observations were made which reveal the conditions in which men
lived when the site was first inhabited. The relevant layers show:

a stratum of irregular thickness composed of refuse resulting from


human occupation—ashes, disintegrated mud brick, potsherds, etc.
This went down almost to sea-level; below it was a belt about one
metre thick of mud, grey in colour above, and darkening to black
below, much of which was clearly due to the decay of vegetation.
In it were potsherds, sporadic above but becoming more numerous
lower down and massed thickly at the bottom, all the fragments
lying horizontally; they had the appearance of having sunk by their
own weight through water into soft mud. At a metre below sea-
level came stiff, green clay pierced by sinuous brown stains
resulting from the decay of roots; with this all trace of human
[82]
activity ceased. Evidently this was the bottom of Mesopotamia.

Southern Mesopotamia resembled the Egyptian Delta, rather than the


Nile valley where cliffs constrain the meanderings of the river, 45
and old banks and spurs provide high ground. In Mesopotamia
the lowest course of Euphrates and Tigris presents, even to-day, a
wilderness of reed forests where the Marsh Arabs lead an amphibious
existence (Fig. 6). All traffic is by narrow bituminous skiffs; the
people fish and keep some cattle, living in reed huts built on
mattresses of bent and trodden-down reed stems. Their dwellings are
described as follows:

at one end is a low and narrow aperture which serves as a


doorway, window and chimney combined; on the rush-strewn and
miry floor sleep men and women, children and buffaloes, in warm
proximity ... the ground of the hut often oozing water at every
[83]
step.

The chiefs’ reed tents are more impressive; they are large tunnels of
matting covering a framework of reed bundles which form
semicircular arches. Doors and windows are arranged in the mats
closing either end. We know that such structures were also used in
the fourth millennium B.C., for they are represented, with all the
necessary detail, in the earliest renderings of sacred buildings,
notably the byres and folds of temple animals (Fig. 5).

But modern savages are but diminished shadows of the true


primitives, and the ancient people of the Al Ubaid period exercised a
mastery over the marsh to which the modern inhabitants never as
much as aspire. Moreover, the people of the Al Ubaid period belonged
to the most advanced group of the prehistoric farmers. Copper was
used in their homeland for axes and adzes and even for mirrors.
Bricks were known there, too; and brick buildings and the
waterproofing of reeds with bitumen are certified for the period. It is
likely that some reclamation and drainage of marshland was 46
undertaken. In any case, the men of the Al Ubaid period
appear from the first as cultivators, and we are free to imagine their
fields as shallow islands in the marsh or as reclaimed and diked-in
land.

The vitality and power of these earliest settlers is astonishing. Their


influence can be traced upstream, where their pottery replaced the
Tell Halaf wares completely, even occurring in appreciable quantities
in North Syria. Since it has nothing to recommend it as an article of
export, we must assume that its makers came with it and settled
widely throughout the upper reaches of Tigris and Euphrates.
Nevertheless, the Al Ubaid people were simple cultivators like their
contemporaries in Egypt and their predecessors in northern Iraq and
Syria. This is most clearly shown by their inability to organize trade in
order to obtain the copper which they had been accustomed to use in
their country of origin. Once settled in Mesopotamia and removed
from the sources of the metal, they used a substitute material that
was locally available, making axes (Fig. 7a), choppers, and sickles
(Fig. 7b) of clay which they fired at so high a temperature that it
almost vitrified and thus obtained a useful cutting edge. These
implements were, of course, very brittle and were broken by the
hundreds. But they could be easily replaced; and the isolated
settlements achieved that autarchy which is characteristic of early
peasant cultures.

And yet the Al Ubaid period has left us some remains which suggest
that certain centres began to be of outstanding importance and that
a change in the rural character of the settlements was taking place.
[84]
At Abu Shahrein in the south, and at Tepe Gawra in the 47
north, temples were erected. And these not only testify to a co-
ordinated effort on a larger scale than we would expect within the
scope of a village culture, but show also a number of features which
continue in historical times—for instance: the simple oblong shape of
the sanctuary, with its altar and offering table; the platforms on
which the temples were set; the strengthening buttresses (which
developed into a system of piers and recesses, rhythmically
articulating the walls). Moreover, it is likely that at Eridu there was
continuity, not only of architectural development, but of worship. In
the absence of inscriptions this contention cannot be proved. But the
god worshipped there in historical times was called Enki—lord of the
earth, but also god of the sweet waters. He is depicted surrounded
by waters (for he “had founded his chamber in the deep”) and fishes
sport in the streams which spring from his shoulders. Now an
observation made during the excavation of the Al Ubaid temples
suggests that the same god was adored in them. At one stage the
offering table and sanctuary were covered with a layer of fish bones
six inches deep, remains, no doubt, of an offering to the god of
whom it was said:

When Enki rose, the fishes rose and adored him.


He stood, a marvel unto the Apsu (Deep),
Brought joy to the Engur (Deep).
To the sea it seemed that awe was upon him,
To the Great River it seemed that terror hovered around him
While at the same time the south wind stirred the depths of the
[85]
Euphrates.
The importance which one attaches to these signs of a possible 48
continuity remains a matter of personal judgment. But, in any
case, the Al Ubaid culture which we have described was the first to
have occupied Mesopotamia as a whole. It seems to have spread
[86]
along the rivers from the south. And it was in the south that, after
an interval, the profound change was brought about which made first
Sumer, and then Babylon, the cultural centre of Western Asia for
three thousand years.

49
III. THE CITIES OF MESOPOTAMIA
The scene we have so far surveyed has been somewhat monotonous.
The differences between the various groups of prehistoric farmers are
insignificant beside the overriding similarity of their mode of life,
relatively isolated as they were and almost entirely self-sufficient in
their small villages. But by the middle of the fourth millennium B.C.
this picture changed, first in Mesopotamia and a little later in Egypt;
and the change may be described in terms of archaeological
evidence. In Mesopotamia we find a considerable increase in the size
of settlements and buildings such as temples. For the first time we
can properly speak of monumental architecture as a dominant
feature of sizable cities. In Egypt, too, monumental architecture
appeared; and in both countries writing was introduced, new
techniques were mastered, and representational art—as distinct from
the mainly decorative art of the preceding period—made its first
appearance.

It is important to realize that the change was not a quantitative one.


If one stresses the increased food supply or the expansion of human
skill and enterprise; or if one combines both elements by proclaiming
irrigation a triumph of skill which produced abundance; even if one
emphasizes the contrast between the circumscribed existence of the
prehistoric villagers and the richer, more varied, and more complex
life in the cities—one misses the point. All these quantitative 50
evaluations lead to generalizations which obscure the very
problem with which we are concerned. For a comparison between
Egypt and Mesopotamia discloses, not only that writing,
representational art, monumental architecture, and a new kind of
political coherence were introduced in the two countries; it also
reveals the striking fact that the purpose of their writing, the contents
of their representations, the functions of their monumental buildings,
and the structure of their new societies differed completely. What we
observe is not merely the establishment of civilized life, but the
emergence, concretely, of the distinctive “forms” of Egyptian and
Mesopotamian civilization.

It is necessary to anticipate here and to substantiate the contrast.


The earliest written documents of Mesopotamia served a severely
practical purpose; they facilitated the administration of large
economic units, the temple communities. The earliest Egyptian
inscriptions were legends on royal monuments or seal engravings
identifying the king’s officials. The earliest representations in
Mesopotamian art are preponderantly religious; in Egyptian art they
celebrate royal achievements and consist of historical subjects.
Monumental architecture consists, in Mesopotamia, of temples, in
Egypt of royal tombs. The earliest civilized society of Mesopotamia
crystallized in separate nuclei, a number of distinct, autonomous
cities—clear-cut, self-assertive polities—with the surrounding lands to
sustain each one. Egyptian society assumed the form of the single,
united, but rural, domain of an absolute monarch.

The evidence from Egypt, which is the more extensive, indicates the
transition was neither slow nor gradual. It is true that towards the
end of the prehistoric period certain innovations heralded the coming
age. But when the change occurred it had the character of a 51
crisis, affecting every aspect of life at once but passing within
the space of a few generations. Then followed—from the middle of
the First until the end of the Third Dynasty—a period of consolidation
and experiment, and with this the formative phase of Egyptian
civilization was concluded. Few things that mattered in Pharaonic
Egypt were without roots in that first great age of creativity.

In Mesopotamia a parallel development possessed a somewhat


different character. It likewise affected every field of cultural activity
at once, but it lacked the finality of its Egyptian counterpart. It
cannot be said of Mesopotamia that its civilization evolved in all its
significant aspects from the achievements of one short period,
decisive as that had been. Mesopotamian history shows a succession
of upheavals, at intervals of but a few centuries, which did more than
modify its political complexion. For instance, the Sumerian language,
[87]
which was dominant throughout the formative phase of
Mesopotamian civilization, was replaced by Semitic Akkadian 52
during the second half of the third millennium. And the shift of
the centre of power, in the third millennium, from Sumer in the
extreme south to Babylonia in the centre, in the second millennium to
Assyria, in the extreme north, brought with it important cultural
changes. Yet notwithstanding all the changes, Mesopotamian
civilization never lost its identity; its “form” was modified by its
turbulent history, but it was never destroyed.

We shall now desist from comparisons and consider the formative


age of Mesopotamia, which is called the Protoliterate period since it
witnessed the invention of writing. To this period the earliest ruins of
cities belong. Now one may say that the birth of Mesopotamian
civilization, like its subsequent growth, occurred under the sign of the
city. To understand the importance of the city as a factor in the
shaping of society, one must not think of it as a mere conglomeration
of people. Most modern cities have lost the peculiar characteristic of
individuality which we can observe in cities of Renaissance Italy, of
Medieval Europe, of Greece, and of Mesopotamia. In these counties
the physical existence of the city is but an outward sign of close
communal affinities which dominate the life of every dweller within
the walls. The city sets its citizens apart from the other inhabitants of
the land. It determines their relations with the outside world. It
produces an intensified self-consciousness in its burghers, to whom
the collective achievements are a source of pride. The communal life
of prehistoric times became civic life.

The change, however, was not without its disadvantages, especially


in a country like Mesopotamia. The modest life of the prehistoric
villager had fitted well enough into the natural surroundings, but the
city was a questionable institution, at variance, rather than in
keeping, with the natural order. This fact was brought home by 53
the frequent floods and storms, droughts and marsh-fires with
which the gods destroyed man’s work. For in Mesopotamia, in
contrast with Egypt, natural conditions did not favour the
development of civilization. Sudden changes could bring about
[88]
conditions beyond man’s control. Spring tides in the Persian Gulf
may rise to a height of eight to nine feet; prolonged southerly gales
may bank up the rivers for as much as two feet or more. Abnormal
snowfalls in Armenia, or abnormal rainfall farther to the south, may
cause a sudden rise of level in the rivers; a landslide in the narrow
gorges of the two Zabs or of the Khabur may first hold up, then
suddenly release, an immense volume of water. Any one of these
circumstances, or the simultaneous occurrence of two or more of
them, may create a flow which the earth embankments in the
southern plain are not able to contain. In prehistoric times when
primitive farmers sowed a catch crop after the inundation, it was
possible to adapt human settlement to the ever-changing distribution
of land and water, even though the villages were frequently
destroyed. But large permanent towns, dependent upon drainage and
irrigation, require unchanging watercourses. This can be achieved
only through relentless vigilance and toil; for the quickly running
Tigris carries so coarse a silt that canals easily get blocked. Even
when cleaned annually, they rise gradually above the plain as a result
of precipitation; and the risk that they, or the rivers themselves, may
burst through their banks is never excluded. In 1831 the Tigris, rising
suddenly, broke its embankment and destroyed 7000 houses in
[89]
Baghdad in a single night.

Small wonder, then, that the boldness of those early people 54


who undertook to found permanent settlements in the shifting
plain had its obverse in anxiety; that the self-assertion which the city
—its organization, its institutions, citizenship itself—implied was
overshadowed by apprehension. The tension between courage and
the awareness of man’s dependence on superhuman power found a
precarious equilibrium in a peculiarly Mesopotamian conception. It
was a conception which was elaborated in theology but which
likewise informed the practical organization of society: the city was
conceived to be ruled by a god.

Theocracy, of course, was not peculiar to Mesopotamia: Egypt, too,


was ruled by a god. But this god was incarnate in Pharaoh; and
whatever may be paradoxical in a belief in the divinity of kings, it at
least leaves no doubt as to the ultimate authority in the state and
subjects the people unreservedly to the ruler’s command. In
Mesopotamia no god was identified with the mortal head of the state.
The world of the gods and the world of men were incommensurate.
Nevertheless, a god was supposed to own the city and its people.
The temple was called the god’s house; and it functioned actually as
the manor-house on an estate, with the community labouring in its
service. We shall describe the organization of the temple community
at the end of this chapter. It is necessary first to survey the actual
remains of the Protoliterate cities—the earliest cities in Mesopotamia.

In Protoliterate ruins the temples are the most striking feature. We


have seen how, in the Al Ubaid period, temples were erected at Eridu
in the south and at Tepe Gawra in the north. But the edifices of 55
the Protoliterate period at Erech are much more impressive.
The temple of the god Anu (Figs. 8, 45) was placed upon an artificial
mound forty feet high and covering an area of about 420,000 square
feet. It dominated the plain for many miles around. Near its base lay
another great shrine, dedicated to the goddess Inanna. Several times
changed and rebuilt, it measured, at one stage, 240 by 110 feet; at
another it possessed a colonnade in which each column measured 9
feet in diameter (Figs. 9, 10). Each of these, and also the adjoining
walls and the sides of the platform supporting them, was covered
with a weatherproof “skin” consisting of tens of thousands of clay
cones, separately made, baked, and coloured. These formed patterns
of lozenges, zigzags, and triangles, and so on, in black and red on a
buff ground. The cones were stuck into a thick mud plaster which
covered the brickwork. The patterning in colour enlivened a façade
already richly articulated by complex systems of buttresses, recesses,
and semi-engaged columns, and thus achieved an effect far beyond
anything which the exclusive use of mud as building material would
suggest as attainable.

The most characteristic feature of Mesopotamian temple architecture


was the artificial mound, called a ziggurat or temple tower (Figs. 8,
11), the tower of Babel being the best known, that of Ur the best
preserved, example. However, ziggurats were not found in connection
with all temples. The Protoliterate temple at Tell Uqair, which has the
same plan and even the same dimensions as the contemporary
temple on the ziggurat at Erech, stands on a platform only a few
[90]
metres high. I am inclined to see in this an abbreviated rendering
of the ziggurat, but the possibility that the two differed in 56
significance cannot be excluded. We cannot explain why some
temples should lack ziggurats; but we can understand why so many
great shrines were equipped with them, and why the staggering
communal effort which their construction entailed was undertaken.

The significance of the ziggurats is revealed by the names which


many of them bear, names which identify them as mountains. That of
the god Enlil at Nippur, for example, was called “House of the
Mountain, Mountain of the Storm, Bond between Heaven and Earth.”
Now “mountain,” as used in Mesopotamia, is a term so heavily
charged with religious significance that a simple translation does it as
little justice as it would to the word “Cross” in Christian, or the words
[91]
“West” or “Nun” (Primeval Ocean) in Egyptian, usage. In
Mesopotamia the “mountain” is the place where the mysterious
potency of the earth, and hence of all natural life, is concentrated.
This is perhaps best understood if we look at a rather rough relief of
terra cotta (Fig. 12) which was found at Assur in a temple of the
second millennium B.C., although similar representations are known
on seals of a much earlier date. The deity represented is clearly 57
a personification of chthonic forces. His body grows out of a
mountain (the scale pattern is the conventional rendering of a
mountainside), and the plants grow from the mountainsides as well
as from the god’s hands. Goats feed on these plants; and water,
indispensable to all life, is represented by two minor deities flanking
the god. Deities like the main figure on this relief were worshipped in
all Mesopotamian cities, although their names differed. Tammuz is
the best known of them. As personifications of natural life they were
thought to be incapacitated during the Mesopotamian summer, which
is a scourge destroying vegetation utterly and exhausting man and
beast. The myths express this by saying that the god “dies” or that
he is kept captive in the “mountain.” From the mountain he comes
forth at the New Year when nature revives. Hence, the mountain is
also the land of the dead; and when the sun god is depicted rising
daily upon the mountains of the East, the scene is not merely a
reminder of the geography of the country. The vivifying rain is also
brought from the mountain by the weather god. Thus the mountain is
essentially the mysterious sphere of activity of the superhuman
powers. The Sumerians created the conditions under which
communication with the gods became possible when they erected the
artificial mountains for their temples.

In doing so they also strengthened their political cohesion. The huge


building, raised to establish a bond with the power upon which the
city depended, proclaimed not only the ineffable majesty of the gods
but also the might of the community which had been capable of such
an effort. The great temples were witnesses to piety, but also objects
of civic pride. Built to ensure divine protection for the city, they also
enhanced the significance of citizenship. Outlasting the 58
generation of their builders, they were true monuments of the
cities’ greatness.

It is in these temples that we find the first signs of a new invention


without which the undertaking of works of this magnitude, or, indeed,
of communal organization on a considerable scale, would not have
[92]
been feasible, that is, writing. From the first it appears in the form
of impressions made by a reed on clay tablets. The earliest of the
tablets, found in the temple at Erech, were memoranda—aids for the
running of the temple as the production centre, warehouse, and
workshop of the community. The simplest were no more than tallies

You might also like