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

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

The document provides links to various editions of Java programming eBooks, including 'Big Java: Early Objects' and 'Java How to Program'. It highlights the educational features of the books, such as integrated coding activities and online resources for instructors. The content focuses on programming fundamentals, object-oriented design, and applied topics relevant to server-side programming.

Uploaded by

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

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

The document provides links to various editions of Java programming eBooks, including 'Big Java: Early Objects' and 'Java How to Program'. It highlights the educational features of the books, such as integrated coding activities and online resources for instructors. The content focuses on programming fundamentals, object-oriented design, and applied topics relevant to server-side programming.

Uploaded by

konartayib4s
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/ 56

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

install download

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

Download more ebook from https://ebookluna.com


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

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

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

ebookluna.com

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


Horstmann

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

ebookluna.com

(eBook PDF) Big Java Late Objects 2nd Edition

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

ebookluna.com

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

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

ebookluna.com
(eBook PDF) Starting Out with Java: Early Objects 5th
Edition

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

ebookluna.com

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


Global Edition

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

ebookluna.com

(eBook PDF) Starting Out with Java Early Objects 6th


Edition by Tony Gaddis

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

ebookluna.com

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


Edition by Paul J. Deitel

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

ebookluna.com

(eBook PDF) Big C++: Late Objects 3rd Edition

https://ebookluna.com/product/ebook-pdf-big-c-late-objects-3rd-
edition/

ebookluna.com
7/e

Cay Horstmann

Big JavaEarly Objects


vi Preface

programming, rather than the more traditional in-depth material on data structures
and algorithms. This book can be used in a two-semester course to give students an
introduction to programming fundamentals and broad coverage of applications.
Alternatively, the material in the final chapters can be useful for student projects. The
applied topics include graphical user-interface design, advanced file handling, multi-
threading, and those technologies that are of particular interest to server-side pro-
gramming: networking, databases, and XML. The Internet has made it possible to

1. Introduction

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

4. Fundamental
Data Types

5. Decisions

6. Loops

Sections 11.1 and 11.2


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

11. Input/Output 8. Designing


13. Recursion
and Exception Classes
Handling

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

19. Stream
22. Processing
20. Graphical
25. XML 10. Interfaces
e e
User Interfaces Multithreading

16. Basic
12. Object- Data Structures
Oriented Design

Figure 1
Chapter 18. Generic 17. Tree
Classes Structures
Dependencies

bjeo_fm.indd 6 11/27/18 1:36 PM


Preface vii

deploy many useful applications on servers, often accessed by nothing more than a
browser. This server-centric approach to application development was in part made
possible by the Java language and libraries, and today, much of the industrial use of
Java is in server-side programming.

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

Interactive eText Designed for Programming Students


Available online through wiley.com, vitalsource.com, or at your local bookstore, the
enhanced eText features integrated student coding activities that foster in-depth
learning. Designed by Cay Horstmann, these activities provide instant feedback to
show students what they did right and where they need to study more. Students do
more than just watch animations and code traces; they work on generating them right
in the eText environment. For a preview of these activities, check out http://wiley.
com/college/sc/horstmann.
Customized formats are also available in both print and digital formats and pro-
vide your students with curated content based on your unique syllabus.
Please contact your Wiley sales rep for more information about any of these
options.

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

• Source code for all example programs in the book and its Worked Examples, plus
additional example programs.
• Worked Examples that apply the problem-solving steps in the book to other
realistic examples.
• Lecture presentation slides (for instructors only).
• Solutions to all review and programming exercises (for instructors only).
• A test bank that focuses on skills, not just terminology (for instructors only). This
extensive set of multiple-choice questions can be used with a word processor or
imported into a course management system.
• CodeCheck®, an innovative online service that allows instructors to design their
own automatically graded programming exercises.

bjeo_fm.indd 7 11/27/18 1:36 PM


viii Walkthrough

Walkthrough of the Learning Aids


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

6.3 The for Loop 183

6.3 The for Loop


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

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


cial form for it, called the for loop (see Syntax 6.2).
for (int counter = 5; counter <= 10; counter++)
{
sum = sum + counter;
}

Some people call this loop count-controlled. In con-


trast, the while loop of the preceding section can
be called an event-controlled loop because it exe-
cutes until an event occurs; namely that the balance
reaches the target. Another commonly used term for
a count-controlled loop is definite. You know from
the outset that the loop body will be executed a defi-
nite number of times; ten times in our example. In
© Enrico Fianchini/iStockphoto.
contrast, you do not know how many iterations it
takes to accumulate a target balance. Such a loop is You can visualize the for loop as
Annotated syntax boxes called indefinite. an orderly sequence of steps.

provide a quick, visual overview


of new language constructs. Syntax 6.2 for Statement

Syntax for (initialization; condition; update)


{
statements
}
These three
expressions should be related.
See Programming Tip 6.1.

Annotations explain required This initialization The condition is This update is


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

Analogies to everyday objects are


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

bjeo_fm.indd 8 11/27/18 1:36 PM


Walkthrough ix

Memorable photos reinforce


analogies and help students
remember the concepts.

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

Problem Solving sections teach


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

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

that most of the planning and problem


solving that makes students successful
happens away from the computer.

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

HOW TO 6.1 How To guides give step-by-step


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

Step 1 Decide what work must be done inside the loop. Worked Examples apply
Every loop needs to do some kind of repetitive work, such as
• Reading another item. the steps in the How To to a
• Updating a value (such as a bank balance or total).
WORKED EXAMPLE 6.1 different example, showing
• Incrementing a counter.
Credit Card Processing
If you can’t figure out what needs to go inside the loop, start by writing down the steps that how they can be used to
you would take if you
howsolved
to use the problem by hand. Forfrom
example, with the temperature reading
problem, you
Learn
might See
number. write
a loop to remove spaces a credit
your eText or visit wiley.com/go/bjeo7.
card
plan, implement, and test
© MorePixels/iStockphoto. a solution to another
programming problem.
Table 1 Variable Declarations in Java
Variable Name Comment

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

int perimeter = 4 * width; The initial value need not be a fixed value. (Of course, width
must have been previously declared.)

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

bjeo_fm.indd 9 11/27/18 1:37 PM


x Walkthrough

Figure 3
Progressive figures trace code Execution of a
1 Initialize counter
for (int counter = 5; counter <= 10; counter++)
{
for Loop
segments to help students visualize counter = 5 }
sum = sum + counter;

the program flow. Color is used


consistently to make variables and
2 Check condition
for (int counter = 5; counter <= 10; counter++)
{

other elements easily recognizable. counter = 5 }


sum = sum + counter;

3 Execute loop body


for (int counter = 5; counter <= 10; counter++)
{
sum = sum + counter;
counter = 5 }

4 Update counter
for (int counter = 5; counter <= 10; counter++)
{
sum = sum + counter;
counter = 6 }
sec01/ElevatorSimulation.java
1 import java.util.Scanner; 5 Check condition again
for (int counter = 5; counter <= 10; counter++)
2 {
3 /** sum = sum + counter;
4 This program simulates an elevator panel that skips the 13th floor. counter = 6 }
5 */
6 public class ElevatorSimulation
7 {
8 public static void main(String[] args)
9 { The for loop neatly groups the initialization, condition, and update expressions
10 Scanner in = new Scanner(System.in); together. However, it is important to realize that these expressions are not executed
11 System.out.print("Floor: ");
together (see Figure 3).
12 int floor = in.nextInt();
13
• The initialization is executed once, before the loop is entered. 1
14 // Adjust floor if necessary
15 • The condition is checked before each iteration. 2 5
16 int actualFloor;
17 if (floor > 13) • The update is executed after each iteration. 4

Program listings are carefully


designed for easy reading, going
well beyond simple color coding.
Students can run and change the
same programs right in the eText.

Self-check exercises in the


eText are designed to engage
students with the new material
and check understanding before
they continue to the next topic.

•• Business E6.17 Currency conversion. Write a program


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

Optional science and business • Science P6.15 Radioactive decay of radioactive materials can be
modeled by the equation A = A0e-t (log 2/h), where A is
exercises engage students with the amount of the material at time t, A0 is the amount
realistic applications of Java. at time 0, and h is the half-life.
Technetium-99 is a radioisotope that is used in imaging
of the brain. It has a half-life of 6 hours. Your program
should display the relative amount A / A0 in a patient
body every hour for 24 hours after receiving a dose.

bjeo_fm.indd 10 11/27/18 1:37 PM


Walkthrough xi

Common Errors describe the kinds Common Error 7.4

of errors that students often make, Length and Size


Unfortunately, the Java syntax for determining the number of elements in an array, an array
with an explanation of why the errors list, and a string is not at all consistent. It is a common error to confuse these. You just have to
remember the correct syntax for every data type.
occur, and what to do about them.
Data Type Number of Elements

Array a.length

Array list a.size()

String a.length()

Programming Tip 5.5


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

more productive with tips and the program run above. When the TaxReturn object is constructed,
the income instance variable is set to 80,000 and status is set to
Hand-tracing helps you
understand whether a
techniques such as hand-tracing. MARRIED. Then the getTax method is called. In lines 31 and 32 of Tax-
Return.java, tax1 and tax2 are initialized to 0.
program works correctly.

29 public double getTax()


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

Special Topic 11.2


File Dialog Boxes

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

Additional full code examples


File selectedFile = chooser.getSelectedFile();
in = new Scanner(selectedFile);

throughout the text provide }

complete programs for students EXAMPLE CODE See special_topic_2 of your eText or companion code for a program that demonstrates how to use a file
chooser.

to run and modify.

Computing & Society 1.1 Computers Are Everywhere


When computers The advent of ubiqui-
were first invented tous computing changed
in the 1940s, a computer filled an many aspects of our
entire room. The photo below shows lives. Factories used
the ENIAC (electronic numerical inte- to employ people to
grator and computer), completed in do repetitive assembly
1946 at the University of Pennsylvania. tasks that are today car-
The ENIAC was used by the military ried out by computer-

Computing & Society presents social


to compute the trajectories of projec- controlled robots, oper-
tiles. Nowadays, computing facilities ated by a few people
of search engines, Internet shops, and who know how to work
and historical topics on computing—for social networks fill huge buildings
called data centers. At the other end of
with those computers.
Books, music, and mov-
interest and to fulfill the “historical and the spectrum, computers are all around
us. Your cell phone has a computer
ies are nowadays often
consumed on com- This transit card contains a computer.
social context” requirements of the inside, as do many credit cards and fare
cards for public transit. A modern car
puters, and comput-
ers are almost always

ACM/IEEE curriculum guidelines. has several computers––to control the


engine, brakes, lights, and the radio.
involved in their production. The
book that you are reading right now
could not have been written without
computers.

bjeo_fm.indd 11 11/27/18 1:37 PM


xii Walkthrough

Interactive activities in the eText


engage students in active reading as they… Complete a program and
get immediate feedback

Trace through a code segment

Arrange code to fulfill a task

Build an example table

Create a memory diagram

Explore common algorithms

bjeo_fm.indd 12 11/27/18 2:30 PM


Acknowledgments xiii

Acknowledgments
Many thanks to Joanna Dingle, Crystal Franks, Graig Donini, and Michael Mac-
Dougald at John Wiley & Sons, and Vickie Piercey at Publishing Services for their
help with this project. An especially deep acknowledgment and thanks goes to Cindy
Johnson for her hard work, sound judgment, and amazing attention to detail.
Special thanks to Stephen Gilbert, Orange Coast College, for his excellent help
with the interactive exercises.
Many thanks to the individuals who worked through the many new activities in
this edition, reviewed the manuscript, made valuable suggestions, and brought errors
and omissions to my attention. They include:
Radhouane Chouchane, Columbus State University
Sussan Einakian, California Polytechnic State University
Jon Hanrath, Illinois Institute of Technology
Brian King, Bucknell University
Kathleen O’Brien, San Jose State University
Eman Saleh, University of Georgia
William Wei, New York Institute of Technology
Each new edition builds on the suggestions and experiences of prior reviewers, con-
tributors, and users. I am grateful for the invaluable contributions these individuals
have made:
Eric Aaron, Wesleyan University Jerry Cain, Stanford University Geoffrey Decker, Northern Illinois
James Agnew, Anne Arundel Adam Cannon, Columbia University
Community College University Suzanne Dietrich, Arizona State
Tim Andersen, Boise State Michael Carney, Finger Lakes University,West Campus
University Community College Mike Domaratzki, University of
Ivan Bajic, San Diego State Robin Carr, Drexel University Manitoba
University Christopher Cassa, Massachusetts H. E. Dunsmore, Purdue University
Greg Ballinger, Miami Dade College Institute of Technology Robert Duvall, Duke University
Ted Bangay, Sheridan Institute Nancy Chase, Gonzaga University Sherif Elfayoumy, University of
of Technology Dr. Suchindran S. Chatterjee, North Florida
Ian Barland, Radford University Arizona State University Eman El-Sheikh, University of
George Basham, Franklin University Archana Chidanandan, Rose- West Florida
Jon Beck, Truman State University Hulman Institute of Technology Henry A. Etlinger, Rochester
Sambit Bhattacharya, Fayetteville Vincent Cicirello, The Richard Institute of Technology
State University Stockton College of New Jersey John Fendrich, Bradley University
Rick Birney, Arizona State Gerald Cohen, The Richard Stockton David Freer, Miami Dade College
University College of New Jersey John Fulton, Franklin University
Paul Bladek, Edmonds Community Teresa Cole, Boise State University David Geary, Sabreware, Inc.
College Deborah Coleman, Rochester Margaret Geroch, Wheeling Jesuit
Matt Boutell, Rose-Hulman Institute of Technology University
Institute of Technology Tina Comston, Franklin University Ahmad Ghafarian, North Georgia
Joseph Bowbeer, Vizrea Corporation Lennie Cooper, Miami Dade College College & State University
Timothy A. Budd, Oregon State Jose Cordova, University of Rick Giles, Acadia University
University Louisiana, Monroe Stacey Grasso, College of San Mateo
John Bundy, DeVry University Valentino Crespi, California State Jianchao Han, California State
Chicago University, Los Angeles University, Dominguez Hills
Robert P. Burton, Brigham Young Jim Cross, Auburn University Lisa Hansen, Western New England
University Russell Deaton, University College
Frank Butt, IBM of Arkansas Elliotte Harold

bjeo_fm.indd 13 11/27/18 1:37 PM


xiv Acknowledgments

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

bjeo_fm.indd 14 11/27/18 1:37 PM


CONTENTS

PREFACE iii 2.4 Constructing Objects 38


SPECIAL FEATURES xxiv 2.5 Accessor and Mutator Methods 40
2.6 The API Documentation 41
1 INTRODUCTION 1 Browsing the API Documentation 41
Packages 43
1.1 Computer Programs 2 2.7 Implementing a Test Program 44
1.2 The Anatomy of a Computer 3 ST2 Testing Classes in an Interactive
1.3 The Java Programming Language 5 Environment 45
WE1 How Many Days Have You Been Alive? 46
1.4 Becoming Familiar with Your
WE2 Working with Pictures 46
Programming Environment 7
2.8 Object References 46
1.5 Analyzing Your First Program 11
2.9 Graphical Applications 49
1.6 Errors 13
Frame Windows 50
1.7 PROBLEM SOLVING Algorithm Design 15 Drawing on a Component 51
The Algorithm Concept 15 Displaying a Component in a Frame 53
An Algorithm for Solving an
Investment Problem 16
2.10 Ellipses, Lines, Text, and Color 54
Pseudocode 17 Ellipses and Circles 54
From Algorithms to Programs 18 Lines 55
HT1 Describing an Algorithm with Drawing Text 56
Pseudocode 18 Colors 56
WE1 Writing an Algorithm for Tiling a Floor 20
3 IMPLEMENTING CLASSES 61
2 USING OBJECTS 23
3.1 Instance Variables and Encapsulation 62
2.1 Objects and Classes 24 Instance Variables 62
Using Objects 24 The Methods of the Counter Class 64
Classes 25 Encapsulation 64

2.2 Variables 26 3.2 Specifying the Public Interface


Variable Declarations 26
of a Class 66
Types 28 Specifying Methods 66
Names 29 Specifying Constructors 67
Comments 30 Using the Public Interface 69
Assignment 30 Commenting the Public Interface 69
ST1 Variable Type Inference 33 3.3 Providing the Class Implementation 72
2.3 Calling Methods 33 Providing Instance Variables 72
The Public Interface of a Class 33 Providing Constructors 73
Method Arguments 34 Providing Methods 75
Return Values 35 HT1 Implementing a Class 78
Method Declarations 36 WE1 Making a Simple Menu 81

xv

bjeo_fm.indd 15 11/27/18 1:37 PM


xvi Contents

3.4 Unit Testing 81 5 DECISIONS 131


3.5 PROBLEM SOLVING Tracing Objects 84
5.1 The if Statement 132
3.6 Local Variables 86
ST1 The Conditional Operator 137
3.7 The this Reference 88
5.2 Comparing Values 137
ST1 Calling One Constructor from Another 90
Relational Operators 138
3.8 Shape Classes 90 Comparing Floating-Point Numbers 139
HT2 Drawing Graphical Shapes 94 Comparing Strings 140
Comparing Objects 141
Testing for null 141
4 FUNDAMENTAL DATA
HT1 Implementing an if Statement 143
TYPES 99
WE1 Extracting the Middle 146
4.1 Numbers 100 5.3 Multiple Alternatives 146
Number Types 100 ST2 The switch Statement 148
Constants 102 5.4 Nested Branches 149
ST1 Big Numbers 106 ST3 Block Scope 154
4.2 Arithmetic 107 ST4 Enumeration Types 155
Arithmetic Operators 107 5.5 PROBLEM SOLVING Flowcharts 156
Increment and Decrement 107
5.6 PROBLEM SOLVING Selecting Test
Integer Division and Remainder 108
Powers and Roots 109 Cases 159
Converting Floating-Point Numbers ST5 Logging 161
to Integers 110 5.7 Boolean Variables and Operators 161
ST2 Avoiding Negative Remainders 112 ST6 Short-Circuit Evaluation of Boolean
ST3 Combining Assignment and Arithmetic 113 Operators 165
ST4 Instance Methods and Static Methods 113 ST7 De Morgan’s Law 165
4.3 Input and Output 114 5.8 APPLICATION Input Validation 166
Reading Input 114
Formatted Output 115
6 LOOPS 171
HT1 Carrying Out Computations 118
WE1 Computing the Volume and Surface Area of 6.1 The while Loop 172
a Pyramid 121
6.2 PROBLEM SOLVING Hand-Tracing 179
4.4 PROBLEM SOLVING First Do it By Hand 121
6.3 The for Loop 183
WE2 Computing Travel Time 122
ST1 Variables Declared in a for Loop
4.5 Strings 122 Header 189
The String Type 122 6.4 The do Loop 190
Concatenation 123
String Input 124 6.5 APPLICATION Processing Sentinel
Escape Sequences 124 Values 192
Strings and Characters 124 ST2 Redirection of Input and Output 194
Substrings 125 ST3 The “Loop and a Half” Problem 194
ST5 Using Dialog Boxes for Input and ST4 The break and continue Statements 195
Output 128 6.6 PROBLEM SOLVING Storyboards 197
6.7 Common Loop Algorithms 199
Sum and Average Value 199
Counting Matches 200

bjeo_fm.indd 16 11/27/18 1:37 PM


Contents xvii

Finding the First Match 200 7.6 Two-Dimensional Arrays 248


Prompting Until a Match is Found 201 Declaring Two-Dimensional Arrays 248
Maximum and Minimum 201 Accessing Elements 249
Comparing Adjacent Values 202 Locating Neighboring Elements 250
HT1 Writing a Loop 203 Accessing Rows and Columns 251
WE1 Credit Card Processing 206 Two-Dimensional Array Parameters 252
6.8 Nested Loops 206 WE2 A World Population Table 253
WE2 Manipulating the Pixels in an Image 209 ST3 Two-Dimensional Arrays with Variable
Row Lengths 254
6.9 APPLICATION Random Numbers and
ST4 Multidimensional Arrays 255
Simulations 209
7.7 Array Lists 255
Generating Random Numbers 210
The Monte Carlo Method 211 Declaring and Using Array Lists 255
Using the Enhanced for Loop with
6.10 Using a Debugger 213 Array Lists 258
HT2 Debugging 215 Copying Array Lists 259
WE3 A Sample Debugging Session 217 Wrappers and Auto-boxing 259
Using Array Algorithms with Array Lists 260
Storing Input Values in an Array List 261
7 ARRAYS AND ARRAY Removing Matches 261
LISTS 221 Choosing Between Array Lists and Arrays 262
ST5 The Diamond Syntax 264
7.1 Arrays 222
Declaring and Using Arrays 222 7.8 Regression Testing 264
Array References 225
Using Arrays with Methods 226
8 DESIGNING CLASSES 271
Partially Filled Arrays 226
ST1 Methods with a Variable Number of 8.1 Discovering Classes 272
Arguments 229
8.2 Designing Good Methods 273
7.2 The Enhanced for Loop 230
Providing a Cohesive Public Interface 273
7.3 Common Array Algorithms 232 Minimizing Dependencies 274
Filling 232 Separating Accessors and Mutators 275
Sum and Average Value 232 Minimizing Side Effects 276
Maximum and Minimum 232 ST1 Call by Value and Call by Reference 278
Element Separators 232 8.3 PROBLEM SOLVING Patterns for
Linear Search 233
Object Data 282
Removing an Element 234
Keeping a Total 282
Inserting an Element 234
Counting Events 283
Swapping Elements 236
Collecting Values 283
Copying Arrays 237
Managing Properties of an Object 284
Reading Input 238
Modeling Objects with Distinct States 284
ST2 Sorting with the Java Library 240
Describing the Position of an Object 285
7.4 PROBLEM SOLVING Adapting
8.4 Static Variables and Methods 286
Algorithms 240
ST2 Alternative Forms of Instance and Static
HT1 Working with Arrays 242 Variable Initialization 289
WE1 Rolling the Dice 245 ST3 Static Imports 290
7.5 PROBLEM SOLVING Discovering Algorithms by 8.5 PROBLEM SOLVING Solve a Simpler
Manipulating Physical Objects 245 Problem First 291

bjeo_fm.indd 17 11/27/18 1:37 PM


xviii Contents

8.6 Packages 295 10.3 The Comparable Interface 350


Organizing Related Classes into Packages 295 ST3 The clone Method and the Cloneable
Importing Packages 296 Interface 352
Package Names 297 10.4 Using Interfaces for Callbacks 355
Packages and Source Files 297 ST4 Lambda Expressions 358
ST4 Package Access 298 ST5 Generic Interface Types 360
HT1 Programming with Packages 299
10.5 Inner Classes 360
8.7 Unit Test Frameworks 300
10.6 Mock Objects 361
10.7 Event Handling 363
9 INHERITANCE 305 Listening to Events 363
9.1 Inheritance Hierarchies 306 Using Inner Classes for Listeners 365

9.2 Implementing Subclasses 310 10.8 Building Applications with Buttons 368

9.3 Overriding Methods 314 10.9 Processing Timer Events 371


ST1 Calling the Superclass Constructor 318 10.10 Mouse Events 374
ST6 Keyboard Events 377
9.4 Polymorphism 319
ST7 Event Adapters 378
ST2 Dynamic Method Lookup and the Implicit
Parameter 322
ST3 Abstract Classes 323 11 INPUT/OUTPUT AND
ST4 Final Methods and Classes 324 EXCEPTION HANDLING 383
ST5 Protected Access 324
HT1 Developing an Inheritance Hierarchy 325 11.1 Reading and Writing Text Files 384
WE1 Implementing an Employee Hierarchy for ST1 Reading Web Pages 387
Payroll Processing 330 ST2 File Dialog Boxes 387
9.5 Object: The Cosmic Superclass 330 ST3 Character Encodings 388

Overriding the toString Method 330 11.2 Text Input and Output 389
The equals Method 332 Reading Words 389
The instanceof Operator 333 Reading Characters 390
ST6 Inheritance and the toString Method 335 Classifying Characters 390
ST7 Inheritance and the equals Method 336 Reading Lines 390
Scanning a String 392
Converting Strings to Numbers 392
10 INTERFACES 339
Avoiding Errors When Reading Numbers 392
10.1 Using Interfaces for Algorithm Mixing Number, Word, and Line Input 393
Formatting Output 394
Reuse 340
ST4 Regular Expressions 395
Discovering an Interface Type 340
ST5 Reading an Entire File 396
Declaring an Interface Type 341
Implementing an Interface Type 343 11.3 Command Line Arguments 396
Comparing Interfaces and Inheritance 345 HT1 Processing Text Files 399
ST1 Constants in Interfaces 346 WE1 Analyzing Baby Names 403
ST2 Nonabstract Interface Methods 347 11.4 Exception Handling 403
10.2 Working with Interface Variables 348 Throwing Exceptions 403
Converting from Classes to Interfaces 348 Catching Exceptions 405
Invoking Methods on Interface Variables 349 Checked Exceptions 407
Casting from Interfaces to Classes 349 Closing Resources 409
WE1 Investigating Number Sequences 350 Designing Your Own Exception Types 410

bjeo_fm.indd 18 11/27/18 1:37 PM


Contents xix

ST6 Assertions 411 14 SORTING AND


ST7 The try/finally Statement 412 SEARCHING 477
11.5 APPLICATION Handling Input Errors 412
14.1 Selection Sort 478
14.2 Profiling the Selection Sort
12 OBJECT-ORIENTED
Algorithm 481
DESIGN 419
14.3 Analyzing the Performance of the
12.1 Classes and Their Responsibilities 420 Selection Sort Algorithm 484
Discovering Classes 420 ST1 Oh, Omega, and Theta 486
The CRC Card Method 421 ST2 Insertion Sort 487
12.2 Relationships Between Classes 423 14.4 Merge Sort 488
Dependency 423 14.5 Analyzing the Merge Sort Algorithm 491
Aggregation 424 ST3 The Quicksort Algorithm 493
Inheritance 425
14.6 Searching 495
HT1 Using CRC Cards and UML Diagrams in
Program Design 426 Linear Search 495
ST1 Attributes and Methods in UML Binary Search 497
Diagrams 426 14.7 PROBLEM SOLVING Estimating the Running
ST2 Multiplicities 427 Time of an Algorithm 500
ST3 Aggregation, Association, and Linear Time 500
Composition 427 Quadratic Time 501
12.3 APPLICATION Printing an Invoice 428 The Triangle Pattern 502
Requirements 429 Logarithmic Time 503
CRC Cards 429 14.8 Sorting and Searching in the Java
UML Diagrams 432 Library 504
Method Documentation 432
Sorting 504
Implementation 434
Binary Search 505
WE1 Simulating an Automatic Teller Machine 439 Comparing Objects 505
ST4 The Comparator Interface 506
13 RECURSION 443 ST5 Comparators with Lambda Expressions 507
WE1 Enhancing the Insertion Sort Algorithm 507
13.1 Triangle Numbers 444
HT1 Thinking Recursively 448
WE1 Finding Files 452
15 THE JAVA COLLECTIONS
FRAMEWORK 511
13.2 Recursive Helper Methods 452
13.3 The Efficiency of Recursion 453 15.1 An Overview of the Collections
Framework 512
13.4 Permutations 459
15.2 Linked Lists 514
13.5 Mutual Recursion 463
The Structure of Linked Lists 515
13.6 Backtracking 469
The LinkedList Class of the Java Collections
WE2 Towers of Hanoi 475 Framework 516
List Iterators 516
15.3 Sets 520
Choosing a Set Implementation 520
Working with Sets 522

bjeo_fm.indd 19 11/27/18 1:37 PM


xx Contents

15.4 Maps 525 Adding and Removing Elements 572


ST1 Updating Map Entries 527 Iterating over a Hash Table 573
HT1 Choosing a Collection 527 ST2 Open Addressing 578
WE1 Word Frequency 528
ST2 Hash Functions 529 17 TREE STRUCTURES 581
15.5 Stacks, Queues, and Priority Queues 531
17.1 Basic Tree Concepts 582
Stacks 531
Queues 532 17.2 Binary Trees 585
Priority Queues 533 Binary Tree Examples 586
15.6 Stack and Queue Applications 534 Balanced Trees 588
A Binary Tree Implementation 589
Balancing Parentheses 534
Evaluating Reverse Polish Expressions 535 WE1 Building a Huffman Tree 590
Evaluating Algebraic Expressions 537 17.3 Binary Search Trees 590
Backtracking 540 The Binary Search Property 591
ST3 Reverse Polish Notation 542 Insertion 592
WE2 Simulating a Queue of Waiting Removal 594
Customers 543 Efficiency of the Operations 595
17.4 Tree Traversal 599
16 BASIC DATA Inorder Traversal 599
STRUCTURES 545 Preorder and Postorder Traversals 601
The Visitor Pattern 602
16.1 Implementing Linked Lists 546 Depth-First and Breadth-First Search 603
The Node Class 546 Tree Iterators 604
Adding and Removing the First Element 547 17.5 Red-Black Trees 605
The Iterator Class 548
Basic Properties of Red-Black Trees 605
Advancing an Iterator 549
Insertion 607
Removing an Element 550
Removal 608
Adding an Element 552
WE2 Implementing a Red-Black Tree 611
Setting an Element to a Different Value 553
Efficiency of Linked List Operations 553 17.6 Heaps 612
ST1 Static Classes 560 17.7 The Heapsort Algorithm 622
WE1 Implementing a Doubly-Linked List 560
16.2 Implementing Array Lists 560 18 GENERIC CLASSES 629
Getting and Setting Elements 560
Removing or Adding Elements 562 18.1 Generic Classes and Type
Growing the Internal Array 563 Parameters 630
16.3 Implementing Stacks and Queues 564 18.2 Implementing Generic Types 631
Stacks as Linked Lists 565 18.3 Generic Methods 634
Stacks as Arrays 566
18.4 Constraining Type Parameters 636
Queues as Linked Lists 567
ST1 Wildcard Types 638
Queues as Circular Arrays 568
18.5 Type Erasure 639
16.4 Implementing a Hash Table 570
ST2 Reflection 642
Hash Codes 570
WE1 Making a Generic Binary Search
Hash Tables 570
Tree Class 643
Finding an Element 572

bjeo_fm.indd 20 11/27/18 1:37 PM


Contents xxi

19 STREAM PROCESSING 645 Check Boxes 687


Combo Boxes 687
19.1 The Stream Concept 646 HT1 Laying Out a User Interface 692
19.2 Producing Streams 648 WE1 Programming a Working Calculator 694

19.3 Collecting Results 649 20.4 Menus 695


ST1 Infinite Streams 651 20.5 Exploring the Swing Documentation 702
19.4 Transforming Streams 652
19.5 Lambda Expressions 654 21 ADVANCED INPUT/OUTPUT*
ST2 Method and Constructor References 656 (ETEXT ONLY)
ST3 Higher-Order Functions 657
21.1 Readers, Writers, and Input/Output Streams
ST4 Higher-Order Functions and
Comparators 658 21.2 Binary Input and Output
19.6 The Optional Type 659 21.3 Random Access
19.7 Other Terminal Operations 661 21.4 Object Input and Output Streams
19.8 Primitive-Type Streams 663 HT1 Choosing a File Format

Creating Primitive-Type Streams 663 21.5 File and Directory Operations


Mapping a Primitive-Type Stream 663 Paths
Processing Primitive-Type Streams 664 Creating and Deleting Files and Directories
19.9 Grouping Results 665 Useful File Operations
Visiting Directories
19.10 Common Algorithms Revisited 667
Filling 667
Sum, Average, Maximum, and Minimum 668 22 MULTITHREADING*
Counting Matches 668 (ETEXT ONLY)
Element Separators 668
Linear Search 669
22.1 Running Threads
Comparing Adjacent Values 669 ST1 Thread Pools

HT1 Working with Streams 670 22.2 Terminating Threads


WE1 Word Properties 672 22.3 Race Conditions
WE2 A Movie Database 673
22.4 Synchronizing Object Access
22.5 Avoiding Deadlocks
20 GRAPHICAL USER ST2 Object Locks and Synchronized Methods
INTERFACES 675 ST3 The Java Memory Model

20.1 Layout Management 676


22.6 APPLICATION Algorithm Animation
Using Layout Managers 676
Achieving Complex Layouts 677 23 INTERNET NETWORKING*
Using Inheritance to Customize Frames 678 (ETEXT ONLY)
ST1 Adding the main Method to the
Frame Class 679 23.1 The Internet Protocol
20.2 Processing Text Input 680 23.2 Application Level Protocols
Text Fields 680 23.3 A Client Program
Text Areas 682
23.4 A Server Program
20.3 Choices 685 HT1 Designing Client/Server Programs
Radio Buttons 685 23.5 URL Connections

*See your eText or visit www.wiley.com/go/bjeo7.

bjeo_fm.indd 21 11/27/18 1:37 PM


xxii Contents

24 RELATIONAL DATABASES* APPENDIX A THE BASIC LATIN AND LATIN-1 SUBSETS


(ETEXT ONLY) OF UNICODE A-1
APPENDIX B JAVA OPERATOR SUMMARY A-5
24.1 Organizing Database Information APPENDIX C JAVA RESERVED WORD SUMMARY A-7
Database Tables APPENDIX D THE JAVA LIBRARY A-9
Linking Tables APPENDIX E JAVA LANGUAGE CODING
Implementing Multi-Valued Relationships GUIDELINES A-38
ST1 Primary Keys and Indexes APPENDIX F TOOL SUMMARY (ETEXT ONLY)
24.2 Queries APPENDIX G NUMBER SYSTEMS (ETEXT ONLY)
Simple Queries APPENDIX H UML SUMMARY (ETEXT ONLY)
Selecting Columns APPENDIX I JAVA SYNTAX SUMMARY (ETEXT ONLY)
Selecting Subsets
APPENDIX J HTML SUMMARY (ETEXT ONLY)
Calculations
Joins
Updating and Deleting Data
GLOSSARY G-1
INDEX I-1
24.3 Installing a Database
CREDITS C-1
24.4 Database Programming in Java
QUICK REFERENCE C-3
Connecting to the Database
Executing SQL Statements
Analyzing Query Results
Result Set Metadata
24.5 APPLICATION Entering an Invoice
ST2 Transactions
ST3 Object-Relational Mapping
WE1 Programming a Bank Database

25 XML* (ETEXT ONLY)


25.1 XML Tags and Documents
Advantages of XML
Differences Between XML and HTML
The Structure of an XML Document
HT1 Designing an XML Document Format

25.2 Parsing XML Documents


25.3 Creating XML Documents
HT2 Writing an XML Document
ST1 Grammars, Parsers, and Compilers

25.4 Validating XML Documents


Document Type Definitions
Specifying a DTD in an XML Document
Parsing and Validation
HT3 Writing a DTD
ST2 Schema Languages
ST3 Other XML Technologies

*See your eText or visit www.wiley.com/go/bjeo7.

bjeo_fm.indd 22 11/27/18 1:37 PM


Contents xxiii

ALPHABETICAL LIST OF SYNTAX BOXES


Arrays 223
Array Lists 256
Assignment 31
Calling a Superclass Method 315
Cast 110
Catching Exceptions 406
Class Declaration 68
Comparisons 138
Constant Declaration 104
Constructor with Superclass Initializer 318
Declaring a Generic Class 632
Declaring a Generic Method 635
Declaring an Interface 342
for Statement 183
if Statement 134
Implementing an Interface 343
Importing a Class from a Package 43
Input Statement 115
Instance Variable Declaration 63
Java Program 12
Lambda Expressions 655
Object Construction 39
Package Specification 296
Subclass Declaration 311
The Enhanced for Loop 231
The instanceof Operator 334
The throws Clause 408
The try-with-resources Statement 409
Throwing an Exception 403
Two-Dimensional Array Declaration 249
while Statement 173
Variable Declaration 27

bjeo_fm.indd 23 11/27/18 1:37 PM


Other documents randomly have
different content
II.—A NIMAL L IFE. F ISHERIES AND S ALT P ANS.
Another remarkable feature of the abyssal waters of the Me­di­ter­ra­‐
nean consists in their poverty of animal life. No doubt there is some
life; the dredgings of the Porcupine and the telegraph cables, which,
on being brought to the surface, were found to be covered with
shells and polypes, prove this. But, compared with those of the
ocean, the depths of the Me­di­ter­ra­nean are veritable deserts.
Edward Forbes, who explored the waters of the Archipelago, arrived
at the conclusion that their abyssal depths were entirely devoid of
life, but he was wrong when he assumed an exceptional case like
this to represent a universal law. Carpenter thinks that this absence
of life in the depths of the Me­di­ter­ra­nean is due to the great quantity
of organic remains which is carried into it by the rivers. These
remains absorb the oxygen of the water, and part with their carbonic
acid, which is detrimental to {29} animal life. In numerous instances
the water of the Me­di­ter­ra­nean contains only one-fourth the normal
quantity of the former gas, but fifty per cent. in excess of the latter.
To the presence of these organic remains the Me­di­ter­ra­nean is
probably indebted for its beautiful azure colour, so different from the
black waters of most oceans. This blue, then, which is justly
celebrated by poets, would thus be caused by the impurity of the
water. M. Delesse has shown that the bottom of nearly the whole of
the Me­di­ter­ra­nean is covered with ooze.
The regions of the Me­di­ter­ra­nean immediately below the surface
abound in animal life, particularly on the coasts of Sicily and
Southern Italy; but nearly all species, whether fish, testacea, or
others, are of Atlantic origin. The Me­di­ter­ra­nean, in spite of its vast
extent, as far as its fauna is concerned, is nothing but a gulf of the
Lusitanian Ocean. Its longitudinal extension and the similarity of
climate in its various portions have favoured the migration of animals
through the Strait of Gibraltar as far as the coasts of Syria. At the
same time, animal life is most varied near this point of entry, and the
species met with in the western basin are generally of greater size
than those which exist in the eastern. A very small proportion of
non-Atlantic species recalls the fact that the Me­di­ter­ra­nean formerly
communicated with the Red Sea and the Indian Ocean. But amongst
a total of more than eight hundred molluscs there are only about
thirty which have reached the seas of Greece and Sicily through the
ancient straits separating Africa from Asia, instead of through the
Strait of Gibraltar.9 The diminution in the number of species in an
easterly direction becomes most striking when we reach the narrow
channel of the Dardanelles and the Bosphorus. The Black Sea, in
fact, differs essentially from the Me­di­ter­ra­nean proper as regards
temperature. It is refrigerated by north-easterly winds sweeping
over its surface, to the extent even of portions of it becoming now
and then covered with a thin coating of ice, adhering to the coast.
The Sea of Azof has frequently disappeared beneath a thick crust of
ice, and even the whole of the Black Sea has been frozen over in
winters of exceptional severity. The cold surface waters, together
with those conveyed into the Black Sea by large rivers, descend to
the bottom, and prove most detrimental to animal life.
Echinodermata and zoophytes are not met with at all in the Black
Sea; certain classes of molluscs, already rare in the Levantine Sea
and the Archipelago, are likewise absent; and the total number of
species of molluscs is only one-tenth of what it is in the Me­di­ter­ra­‐
nean. Fish are numerous as far as individuals go, but their species
are few. In fact, the fauna of the Black Sea appears to resemble that
of the Caspian, from which it is cut off, rather than that of the Greek
seas, with which the Sea of Marmara connects it.
In addition to the species which have found a second home in the
Me­di­ter­ra­nean, there are some that must still be looked upon as
visitors. Such are the sharks, which extend their incursions to the
seas of Sicily, to the Adriatic, and even to the coasts of Egypt and
Syria. Such, also, are the larger cetacea—whales, rorquals, and
sperm whales—whose visits, however, are confined now to the
Tyrrhenian {30} basin, and become less frequent from century to
century. The tunny-fish of the Me­di­ter­ra­nean are also visitors from
the coasts of Lusitania. First-rate swimmers, they enter through the
Strait of Gibraltar in spring, ascend the whole of the Me­di­ter­ra­nean,
make the tour of the Black Sea, and return in autumn to the Atlantic,
after having accomplished a journey of some 5,600 miles. In the
opinion of the fishermen the tunnies go upon their travels in three
immense divisions or shoals, and it is the central shoal which visits
the coasts of the Tyrrhenian Sea, and consists of the largest and
strongest fish. Each of the three divisions appears to be composed
of individuals about the same age. For mutual protection they swim
in troops, for they are preyed upon by enemies innumerable.
Dolphins and other fish of prey follow their track, but their great
destroyer is man. In the summer the tunny fishery, or tonnaro , is
carried on in numerous bays of Sicily, Sardinia, Naples, and of
Provence. Enormous structures consisting of nets enclose these
bays, and they are ingeniously arranged so as to close gradually
around the captured fish, which, passing from net to net, find
themselves at last in the “chamber of death,” where they are
massacred. Millions of pounds of flesh are annually obtained from
these floating “slaughter-houses,” yet the tunny appears year after
year in multitudes, and on the same coasts. There may have been a
slight decrease in the number, but their closely packed masses still
invade the “Golden Horn” of Byzance and other bays, as they did
when first they attracted the attention of Greek naturalists.
Fig. 7.—T HE P RINCIPAL F ISHERIES OF THE M EDITERRANEAN. Μ
Scale 1 : 38,300,000.

Next to the tunny fisheries those of the sardines and anchovies


are most important. Sea-urchins and other products of the sea are
eaten by the inhabitants of the coasts, particularly in Italy, but there
is no part of the Me­di­ter­ra­nean where animal life is so abundant and
so prodigious in quantity as on the celebrated banks of
Newfoundland, or on the coasts of Portugal or of the Canaries.
A large number of fishing-boats are engaged, not in the capture of
fish, but in {31} the collection of articles of dress or of the toilet. The
purple-shell fisheries on the coasts of Phœnicia, the Peloponnesus,
and Greece are no longer carried on, but hundreds of boats are
employed annually during the fine season in fishing for coral or
sponges.
Coral is found most abundantly in the western portion of the Me­di­‐
ter­ra­nean, and the Italian fishermen do not confine themselves to
their own shores—to Sicily, Naples, and Sardinia—but also visit the
Strait of Bonifacio, the sea off St. Tropez, the vicinity of Cape Creus
in Spain, and the waters of Barbary. Ordinary sponges are collected
in the Gulf of Gabes, and at the other extremity of the Me­di­ter­ra­‐
nean, on the coasts of Syria and Asia Minor, and in the straits
winding between the Cyclades and Sporades. Sponges are usually
found at a depth of from 12 to 150 feet, and can be gathered by
divers; whilst coral occurs at far greater depths, and has to be
wrenched off with an iron instrument, which brings up its fragments,
mixed with ooze, seaweeds, and the remains of marine animalculæ.
This industry is still in a state of barbarism: those devoted to it are
not as yet sufficiently acquainted with the sea and its inhabitants to
enable them to carry on the sponge and coral fisheries in a rational
manner. Yet this they must aim at: they must learn how to deprive
Proteus, the ever-changing deity, of his dominion over the
inhabitants of the deep.
Next to the fisheries, the preparation of sea salt constitutes one of
the leading industries of the Me­di­ter­ra­nean coast-lands. But this
industry, too, is frequently carried on in a primitive way, and only in
the course of the present century have scientific methods been
introduced in connection with it. The Me­di­ter­ra­nean is admirably
suited for the production of salt, for its waters have a high
temperature, they hold a very large quantity of salt in solution, the
rise and fall of the tides are inconsiderable, and flat seashores
alternate with steep coasts and promontories. The most productive
salt marshes of the Me­di­ter­ra­nean are probably those on the
Lagoon, or Étang de Thau, near Cette, and on the littoral of Hyères;
but considerable ones may also be met with on the coasts of Spain,
in Italy, in Sardinia, Sicily, Istria, and even on the “limans” of
Bessarabia, bordering upon the Black Sea. The annual production of
salt is estimated at more than a million tons, and exceeds, therefore,
the entire tonnage of the commercial marine of France.10 But this
quantity, large as it is, is infinitesimal if we compare it with the saline
contents of the sea, and science will enable us one day to raise a far
11
more abundant treasure from its sterile depths.
III.—C OMMERCE AND N AVIGATION.
Whatever advantages may be yielded by fisheries and salt-works,
they shrink into insignificance if we compare them with the great
gain—material, intellectual, {32} and moral—which mankind has
derived from the navigation of this inland sea. It has repeatedly
been pointed out by historians that the disposition of the coasts,
islands, and peninsulas of the Me­di­ter­ra­nean of the Phœnicians and
Greeks admirably favoured the first essays in maritime commerce.
Many causes have contributed to make this sea the cradle of
European commerce: the faint summits of distant lands visible even
before the port has been quitted; numerous nooks along the coasts
where a safe refuge may be found in case of storms; regular land
and sea breezes; an equability of climate which makes the sailor feel
at home wherever business takes him; and, moreover, a great
variety of productions resulting from the diverse configuration of the
Me­di­ter­ra­nean coast-lands. And this commerce, does it not lead to a
peaceful intercourse between peoples on neutral ground, and to
mutual enlightenment, brought about by an interchange of ideas?
Every coast-line which facilitates the intercourse between nations is,
therefore, of immense value as a means of developing civilisation.
Civilisation for many centuries marched from the south-east
towards the north-west, and Phœnicia, Greece, Italy, and France
have successively become great centres of human intelligence. This
historical phenomenon is due to the configuration of the sea, which
has been the vehicle of migratory nations. In fact, the axis of
civilisation, if this expression be allowed, has become confounded
with that axis of the Me­di­ter­ra­nean which extends from the coast of
Syria to the Gulf of Lions, on the coast of France. But the Me­di­ter­ra­‐
nean has ceased to be the only centre of gravitation of Europe,
which sends its merchantmen now to the two Americas and the
farthest East; and civilisation no longer marches in that general line
from east to west, but rather radiates in all directions. Civilising
streams depart from England and Germany towards Northern
America, and from the Latinised countries of Europe towards
Southern America. Their direction is still westerly, but they have
been deflected towards the south, to meet the conditions imposed
by climate and the geographical configuration of land and sea.
It is interesting to trace the changes which have occurred in the
historical importance of the Me­di­ter­ra­nean. As long as that sea
remained the great highway between nations, the commercial
republics were content to extend this highway towards the east, by
establishing caravan routes to the Gulf of Persia, to India, and to
China. In the Middle Ages Genoese factories dotted the coasts of the
Black Sea, and extended thence through Trans-Caucasia as far as
the Caspian. European travellers, and particularly Italians, at that
time crossed Western Asia in all directions; and many a route hardly
known in our days was then frequented almost daily. But for several
centuries direct commercial intercourse with Central Asia has
dwindled down to small proportions.
The Me­di­ter­ra­nean had ceased to be a great ocean highway. Our
navigators, no longer dreading a boundless sea, took their ships into
every part of the ocean. The difficult and perilous land routes were
abandoned, the once busy markets of Central Asia became solitudes,
and the Me­di­ter­ra­nean itself a veritable blind alley, as far as the
world’s commerce was concerned. This condition of affairs lasted for
many years, but since the middle of this century our relations with
the East have {33} been renewed, and the lost ground is rapidly being
recovered. Within the last year a great commercial revolution has
been effected through the opening of one of the ancient gates of the
Me­di­ter­ra­nean, and the Suez Canal has become the great highway of
steamers between Western Europe, the Indies, and Australia.
Possibly, at no distant future, a similar canal will enable our
merchantmen to proceed from the Black Sea to the Caspian, and
perhaps even to the Amu and the Syr, in the very heart of the
ancient continent.
It is thus that the great centres of in­ter­com­mu­ni­ca­tion, or vital
points of our planet, as we should like to call them, become shifted
in the course of time. Port Said, an improvised town on a desert
shore, has thus become a centre of attraction for travellers and
merchandise, whilst the neighbouring cities of Tyre and Sidon have
dwindled down into miserable villages, with nothing to indicate the
proud position they held in the past. Carthage, too, has perished,
and Venice decayed. Many a thriving place on the shores of the Me­‐
di­ter­ra­nean has been reduced to insignificance through the silting up
of its harbour, the employment of larger vessels, the loss of
independence, or through political changes of all kinds. But in nearly
every instance some neighbouring town has taken the place of these
decayed harbours, and most of the great routes of commerce have
maintained their original directions, and their terminal points, as well
as intermediate stations, have remained in the same localities.
There are, moreover, certain places which ships are almost obliged
to frequent, and where towns of importance arise as a matter of
course. Such are the Straits of Gibraltar and of Messina; such, also,
are places like Genoa, Trieste, and Saloniki, which occupy the
bottom of gulfs or bays penetrating far into the land. Ports offering
the greatest facilities for embarking merchandise intended for
foreign countries, such as Marseilles and Alexandria, are likewise
natural centres of attraction to merchants. One town there is in the
Me­di­ter­ra­nean which enjoys at one and the same time every one of
the geographical advantages which we have pointed out, for it is
situated on a strait connecting two seas and separating two
continents. This town is Constantinople, and despite the deplorable
mal­ad­mi­ni­stra­tion under which it suffers, its position alone has
enabled it to maintain its place amongst the great cities of the world.
The ports of the Me­di­ter­ra­nean no longer enjoy a monopoly of
commerce as they did for thousands of years, but the number of
ships to be met with in that inland sea is, nevertheless,
proportionately far greater than what we meet with on the open
oceans. The commercial marine of the Me­di­ter­ra­nean numbers
thirty-seven thousand vessels, of a capacity of two million seven
hundred and ninety-six thousand tons, without counting fishing-
boats. This is more than one-fourth of the entire commercial marine
of the world, as respects the number of ships, and one-sixth of it as
regards tonnage. This inferiority of tonnage is due to the small
vessels of ancient types which still maintain their ground in Greece
and Italy, and which possess certain advantages for the coasting
trade.
To this marine of the Me­di­ter­ra­nean should be added the vessels
belonging to foreign ports, which visit it for purposes of trade, and
amongst which those of {34} England take the most prominent rank.
The Government of Great Britain has even taken care to secure itself
a place amongst the Me­di­ter­ra­nean powers. It has occupied
Gibraltar, at the eastern entrance to this basin, and taken possession
of Malta, which commands its centre; and although the western
entrance, formed by the Suez Canal, is not in its possession, its
garrisons on Perim and the rock of Aden are able at any moment to
close up the only approach to it which leads from the Indian Ocean
through the Red Sea.
Fig. 8.—S TEAMER R OUTES AND T ELEGRAPHS IN THE M EDITERRANEAN. Μ
Scale 1 : 45,000,000.

The share which England takes in the commerce of the Me­di­ter­ra­‐


nean is considerable, but it is surpassed by far by that of France and
Italy. A sovereign who aspired to the dominion of the world once
spoke of the inland sea extending from the Strait of Gibraltar to
Egypt as a “French lake;” but with equal justice might it be called a
Greek, a Dalmatian, or Spanish lake, and with still greater an Italian
lake. The pirates of Barbary were, in reality, the last “masters” of the
Me­di­ter­ra­nean: their swift vessels presented themselves
unexpectedly before the coast towns, and carried off their
inhabitants. But since their predatory fleets have been destroyed,
the Me­di­ter­ra­nean has become the common property of the world,
and the meshes of an international network of maritime highways
become closer from year to year. The merchantmen no longer
pursue their voyages in company as they did in former times,
discharging their cargo from port to port, for a single vessel may
venture now into any portion of the Me­di­ter­ra­nean in safety. Still
there remain the dangers of reefs and of storms. The art of
navigation has made vast progress; most of the capes, at least on
the coasts of Europe, are lit up by lighthouses; the approaches to
the ports are rendered easy by lightships, buoys, and beacons; but
shipwrecks are nevertheless of frequent occurrence. Even large
vessels founder sometimes, without leaving a stray plank behind to
indicate the place of their disappearance.
Steamers travelling along prescribed routes are now gradually
taking the place of sailing vessels, and where they cross at frequent
intervals they may be {35} likened to ferry-boats crossing a river. The
regularity and speed of these steam ferries; the facilities which they
afford for the conveyance of merchandise; the increasing number of
railways which convey the produce of the interior to the seaports;
and lastly, the submarine telegraphs, which have established
instantaneous means of communication between the principal ports,
all contribute towards the growth of Me­di­ter­ra­nean commerce. This
commerce, including imports and exports, and the transit through
12
the Suez Canal, actually amounts to about £353,000,000, a year.
This may not be much for a maritime population of a hundred
millions, but a perceptible increase is taking place from year to year.
We should also bear in mind that, face to face with the busy
peninsulas of Europe, there lies torrid Africa, an inert mass, avoided
by the sailors of our own age as much as it was by those of ancient
Greece. Its coasts are hardly ever visited, with the exception of
those portions which extend from Oran to Tunis, and from
Alexandria to Port Said. It is matter of surprise, too, that certain
localities which formerly attracted crowds of vessels, such as
Cyrenaica, Cyprus, and beautiful Crete, at the very entrance to the
Archipelago, should still remain outside the ordinary track of our
steamers.
GREECE.

I.—G ENERAL A SPECTS.


REECE, within its confined political boundaries, to the
south of the Gulfs of Arta and Volo, is a country of
about nineteen thousand square miles, or at most equal
to the ten-millionth part of the earth’s surface. Within
the vast empire of Russia there are many districts more
extensive than the whole of Greece, but there is nothing which
distinguishes these from other districts which surround them, and
their names call forth no idea in our mind. The little country of the
Hellenes, however, so insignificant upon our maps—how many
memories does it not awaken ! In no other part of the world had
man attained a degree of civilisation equally harmonious in all
respects, or more favourable to individual development. Even now,
though carried along within an historical cycle far more vast than
that of the Greeks, we should do well to look back frequently in
order to contemplate those small nations, who are still our masters
in the arts, and first initiated us into science. The city which was the
“school of Greece” still remains the school of the entire world; and
after twenty centuries of decay, like some of those extinct stars
whose luminous rays yet reach the earth, still continues to enlighten
us.
The considerable part played by the people of Greece during many
ages must undoubtedly be ascribed to the geographical position of
their country. Other tribes having the same origin, but inhabiting
countries less happily situated—such, for instance, as the Pelasgians
of Illyria, who are believed to be the ancestors of the Albanians—
have never risen above a state of barbarism, whilst the Hellenes
placed themselves at the head of civilised nations, and opened fresh
paths to their enterprise. If Greece had remained for ever what it
was during the tertiary geological epoch—a vast plain attached to
the deserts of Libya, and run over by lions and the rhinoceros—
would it have become the native country of a Phidias, an Æschylos,
or a Demosthenes? Certainly not. It would have shared the fate of
Africa, and, far from taking the initiative in civilisation, would have
waited for an impulse to be given to it from beyond. {37}
Greece, a sub-peninsula of the peninsula of the Balkans, was even
more completely protected by transverse mountain barriers in the
north than was Thracia or Macedonia. Greek culture was thus able to
develop itself without fear of being stifled at its birth by successive
invasions of barbarians. Mounts Olympus, Pelion, and Ossa, towards
the north and east of Thessaly, constituted the first line of
formidable obstacles towards Macedonia. A second barrier, the steep
range of the Othrys, runs along what is the present political
boundary of Greece. To the south of the Gulf of Lamia a fresh
obstacle awaits us, for the range of the Œta closes the passage, and
there is but the narrow pass of the Thermopylæ between it and the
sea. Having crossed the mountains of the Locri and descended into
the basin of Thebæ, there still remain to be crossed the Parnes or
the spurs of the Cithæron before we reach the plains of Attica. The
“isthmus” beyond these is again defended by transverse barriers,
outlying ramparts, as it were, of the mountain citadel of the
Peloponnesus, that acropolis of all Greece. Hellas has frequently
been compared to a series of chambers, the doors of which were
strongly bolted; it was difficult to get in, but more difficult to get out
again, owing to their stout defenders. Michelet likens Greece to a
trap having three compartments. You entered, and found yourself
taken first in Macedonia, then in Thessaly, then between the
Thermopylæ and the isthmus. But the difficulties increase beyond
the isthmus, and Lacedæmonia remained impregnable for a long
time.
At an epoch when the navigation even of a land-locked sea like
the Ægean was attended with danger, Greece found herself
sufficiently protected against the invasions of oriental nations; but,
at the same time, no other country held out such inducements to
the pacific expeditions of merchants. Gulfs and harbours facilitated
access to her Ægean coasts, and the numerous outlying islands were
available as stations or as places of refuge. Greece, therefore, was
favourably placed for entering into commercial intercourse with the
more highly civilised peoples who dwelt on the opposite coasts of
Asia Minor. The colonists and voyagers of Eastern Ionia not only
supplied their Achæan and Pelasgian kinsmen with foreign
commodities and merchandise, but they also imparted to them the
myths, the poetry, the sciences, and the arts of their native country.
Indeed, the geographical configuration of Greece points towards the
east, whence she has received her first enlightenment. Her
peninsulas and outlying islands extend in that direction; the
harbours on her eastern coasts are most commodious, and afford
the best shelter; and the mountain-surrounded plains there offer the
best sites for populous cities. Greece, at the same time, does not
share the disadvantage of Turkey, which is almost cut off from the
western world by a mountain region difficult to cross. The Ionian
Sea, to the west of the Peloponnesus, it is true, is, comparatively
speaking, a desert; but farther north the Gulf of Corinth almost cuts
in two the Greek peninsula, and the sight of the distant mountains of
Italy, which are visible from the Ionian Islands, must have incited to
an exploration of the western seas. The Acarnanians, who knew how
to build vaults long before the Romans, were thus brought early into
contact with the Italians, to whom they imparted their {38}
knowledge, and at a subsequent period the Greeks became the
civilisers of the whole western world of the Me­di­ter­ra­nean.
The most distinctive feature of Hellas, as far as concerns the relief
of the ground, consists in the large number of small basins,
separated one from the other by rocks or mountain ramparts. The
features of the ground thus favoured the division of the Greek
people into a multitude of independent republics. Every town had its
river, its amphitheatre of hills or mountains, its acropolis, its fields,
pastures, and forests, and nearly all of them had, likewise, access to
the sea. All the elements required by a free community were thus to
be found within each of these small districts, and the neighbourhood
of other towns, equally favoured, kept alive perpetual emulation, too
frequently degenerating into strife and battle. The islands of the
Ægean Sea, likewise, had constituted themselves into miniature
republics. Local institutions thus developed themselves freely, and
even the smallest island of the Archipelago has its great
representatives in history.
But whilst there thus exists the greatest diversity, owing to the
configuration of the ground and the multitude of islands, the sea
acts as a binding element, washes every coast, and penetrates far
inland. These gulfs and numerous harbours have made the maritime
inhabitants of Greece a nation of sailors—amphibiæ, as Strabo called
them. From the most remote times the passion for travel has always
been strong amongst them. When the inhabitants of a town grew
too numerous to support themselves upon the produce of their land,
they swarmed out like bees, explored the coasts of the Me­di­ter­ra­‐
nean, and, when they had found a site which recalled their native
home, they built themselves a new city. It was thus Greek cities
arose in hundreds of places, from the Mæotis Palus to beyond the
columns of Hercules—from Tanais and Panticapæum to Gades and
Tingis, the modern Tangier. Thanks to those numerous colonies,
some of them more powerful and renowned than the mother towns
which gave birth to them, the veritable Greece, the Greece of
science and art and republican independence, in the end overflowed
its ancient cradle, and sporadically occupied the whole circumference
of the Me­di­ter­ra­nean. The Greeks held the same position relatively
to the world of the ancients which is occupied at the present time by
the Anglo-Saxons with reference to the entire earth. There exists,
indeed, a remarkable analogy between Greece, with its archipelago,
and the British Islands, at the other extremity of the continent.
Similar geographical advantages have brought about similar results,
as far as commerce is concerned, and between the Ægean and the
British seas time and space have effected a sort of harmony.

The admiration with which travellers behold Greece is due, above


all, to the memories attaching to every one of its ruins, to the
smallest amongst its rivulets, and the most insignificant rock in its
seas. Scenery in Provence or Spain, though it may surpass in grace
or boldness of outline anything to be seen in Greece, is appreciated
only by a few. The mass go past it without emotion, for names like
Marathon, Leuctra, or Platææ are not connected with it, and the
rustle of bygone ages is not heard. But even if glorious memories
were not associated with the {39} coasts of Greece, their beauty
would nevertheless entitle them to our admiration. In the gulfs of
Athens or of Argos the artist is charmed not only with the azure blue
of the waters, the transparency of the sky, the ever-changing
perspective along the shores, and the boldness of the promontories,
but also with the pure and graceful profile of the mountains, which
consist of layers of limestone or of marble. We almost fancy we look
upon architectural piles; and the temples with which many a summit
is adorned appear to epitomize them.
It is verdure and the sparkling water of rivulets which we miss
most on the shores of Greece. Nearly all the mountains near the
coast have been despoiled of their large trees. There remain only
bushes, mastic, strawberry, and juniper trees, and evergreen oaks;
even the carpet of odoriferous herbs which clothes the declivities,
and upon which the goat browses, has in many instances been
reduced to a few miserable patches. Torrents of rain have carried
away the mould, and the naked rock appears on the surface. From a
distance we only see greyish declivities, dotted here and there with a
few wretched shrubs. Even in the days of Strabo most mountains
along the coasts had been robbed of their forests, and one of our
modern authors says that “Greece is a skeleton only of what it used
to be !” By a sort of irony, geographical names derived from trees
abound throughout Hellas and Turkey: Caryæ is the “town of walnut-
trees,” Valanidia that of the Valonia oaks, Kyparissi that of cypresses,
Platanos or Plataniki that of plane-trees. Everywhere we meet with
localities whose appellation is justified by nothing. Forests at the
present day are confined almost entirely to the interior and to the
Ionian coast. The Œta Mountains, some of the mountains of Ætolia,
the hills of Acarnania, and Arcadia, Elis, Triphylia, and the slopes of
the Taygetus, in the Peloponnesus, still retain their forests. And it is
only in these forest districts, visited solely by herdsmen, that savage
animals, such as the wolf, the fox, and the jackal, are now met with.
The chamois, it is said, still haunts the recesses of the Pindus and
Œta Mountains; but the wild boar of the Erymanthus, which must
have been a distinct species if we are to judge by antique
sculptures, exists no more in Greece, and the lion, still mentioned by
Aristotle, has not been seen for two thousand years. Amongst the
smaller animals there is a turtle, common in some parts of the
Peloponnesus, which the natives look upon with the same aversion
as do many western nations upon the toad and the salamander.
Greece is a small country, but the variety of its climate is
nevertheless great. Striking differences in the climate of different
localities are produced by the contrasts between mountains and
plains, woodlands and sterile valleys, coasts having a northern or
southern aspect. But even leaving out of sight these local
differences, it may safely be asserted that the varieties of climate
which we meet with in traversing Greece from north to south are
scarcely exceeded in any other region. The mountains of Ætolia, in
the north, whose slopes are covered with beech-trees, remind us of
the temperate zone of Europe, whilst the peninsulas and islands
towards the east and south, with their thickets of fig and olive trees,
their plantations of oranges and lemons, their aloe hedges and rare
palm-trees, belong to the sub-tropical zone. But even neighbouring
districts occasionally {40} differ strikingly as regards climate. In the
ancient lake basin of Bœotia the winters are cold, the summers
scorching, whilst the temperature of the eastern shore of Eubœa is
equable, owing to the moderating influence of sea breezes. Within a
narrow compass Greece presents us with the climates of a large
portion of the earth, and there can be no doubt that this diversity of
climate, and the contrasts of every kind springing from it, must have
favourably influenced the intellectual development of the Hellenes. A
spirit of inquiry was called forth amongst them which reacted upon
their commercial tastes and industrial proclivities.
The diversity of the climate of the land, however, is compensated
for, in Greece, by a uniformity in the climate of the maritime districts.
As in a mountain valley, the winds of the Ægean Sea blow
alternately in contrary directions. During nearly the whole of summer
the atmospheric currents of Eastern Europe are attracted towards
the African deserts. The winds from the north of the Archipelago and
Macedonia then speed the navigator on his voyage to the south, and
on many occasions the conquering tribes of the northern shores of
that sea have availed themselves of them in their improvised attacks
upon the inhabitants of the more southern districts of Asia Minor and
of Greece. These regular northerly currents, known as etesian or
annual winds, cease on the termination of the hot season, when the
sun stands above the southern tropic. They are, moreover,
interrupted every night, when the cool sea air is attracted by the
heated surface of the land. When the sun has set the wind gradually
subsides; there is a calm, lasting a few moments; and then the air
begins to move in an inverse direction—“the land begins to blow,” as
the sailors say. Nor is this regular wind without its counter-current,
known as the embates , or propitious south-easterly breeze of which
the poets sing. General winds and breezes, moreover, are deflected
from their original directions in consequence of the configuration of
the coast and the direction of mountain chains. The Gulf of Corinth,
for instance, is shut in by high mountains on the north and the
south, and the winds alternately enter it from the east or west—a
phenomenon likened by Strabo to the breathing of an animal.
The rains, like the winds, deviate in many places from the
average, and whilst the water pours down into some mountain
valleys as into a funnel, elsewhere the clouds drift past without
parting with a drop of their humid burden. Contrasts in the amount
of precipitation are thus added to those resulting from differences of
configuration and variety of climate. As a rule, rain is more abundant
on the western shores of Greece than on the eastern, and this fact
accounts for the smiling aspect of the hills of Elis, as compared with
the barren declivities of Argolis and Attica. Thunder-storms, driven
before the winds of the Me­di­ter­ra­nean, likewise recur with greater
regularity in the western portion of the peninsula. In Elis and
Acarnania the roll of thunder may be heard in spring daily, for whole
weeks, in the afternoon. No sites more apposite could have been
found for temples dedicated to Jupiter, the god of lightning.

The ancient inhabitants of the Cyclades, and probably, also, those


of the coasts {41} of Hellas and Asia Minor, had already attained a
considerable amount of culture long before the commencement of
our historical records. This has been proved by excavations made in
the volcanic ashes of Santorin and Therasia. At the time their houses
were buried beneath the ashes, the Santoriniotes had begun to pass
from the age of stone into that of copper. They knew how to build
arches of stone and mortar, they manufactured lime, used weights
made of blocks of lava, wove cloth, made pottery, dyed their stuffs,
and ornamented their houses with frescoes; they cultivated barley,
peas, and lentils, and had begun to trade with distant countries.
We do not know whether these men were of the same race as the
Hellenes; but thus much is certain—that at the earliest dawn of
history the islands and coasts of the Ægean Sea were peopled by
various families of Greeks, whilst the interior of the country and the
western shores of the peninsula were inhabited by Pelasgians. These
Pelasgians, moreover, were of the same stock as the Greeks, and
they spoke a language derived from the same source as the dialects
of the Hellenes. Both were Aryans, and, unless natives of the soil,
they must have immigrated into Greece from Asia Minor by crossing
the Hellespont, or by way of the islands of the Archipelago. The
Pelasgians, according to tradition, sprang from Mount Lycæus, in the
centre of the Peloponnesus; they boasted of being “autochthons,”
“men of the black soil,” “children of oaks,” or “men born before the
moon.” All around them lived tribes of kindred origin, such as the
Æolians and the Leleges, and these were afterwards joined by
Ionians and Achæans. The Ionians, who, in a subsequent age,
exercised so great an influence over the destinies of the world, only
occupied the peninsula of Attica and the neighbouring Eubœa. The
Achæans for a long time enjoyed a preponderance, and in the end
the Greek clans collectively became known by that name. Later on,
when the Dorians had crossed the Gulf of Corinth where it is
narrowest, and established themselves as conquerors in the
Peloponnesus, the Amphictyons, or national councils, sitting
alternately at Thermopylæ and Delphi, conferred the name of
Hellenes, which was that of a small tribe in Thessaly and Phthiotis,
upon all the inhabitants of the peninsula and the islands. The name
of Greek, which signifies, perhaps, “mountaineer,” “ancient,” or “son
of the soil,” gradually spread amongst the nation, and in the end
became general. The Ionians of Asia Minor, and the Carians of the
Sporades, emulated the Phœnicians by trading from port to port
amongst these half-savage tribes, and, like bees which convey the
fecundating pollen from flower to flower, they carried the civilisation
of Egypt and the East from tribe to tribe.
Fig. 9.—M AINOTE AND S PARTAN.

Phœnician merchants and Roman conquerors scarcely modified


the elements composing the population of Hellas, but during the age
of migrations barbarians in large numbers penetrated into Greece.
For more than two centuries did the Avares maintain themselves in
the Peloponnesus. Then came the Slavs, aided, on more than one
occasion, by the plague in depopulating the country. Greece became
a Slavonia, and a Slavonian language, probably Servian, was
universally spoken, as is proved by the majority of geographical
names. The superstitions and legends {42} of the modern Greeks, as
has been remarked by many authors, are not simply a heritage
derived from the ancient Hellenes, but have become enriched by
phantoms and vampires of Slav invention. The dress of the Greeks,
too, is a legacy of their northern conquerors. But, in spite of this, the
polished language of the Hellenes {43} has regained by degrees its
ancient preponderance, and the race has so thoroughly
amalgamated these foreign immigrants, that it is impossible now to
trace any Servian elements in the population. But hardly had Hellas
escaped the danger of becoming Slav when it was threatened with
becoming Albanian. This occurred during the dominion of Venice. As
recently as the commencement of the present century Albanian was
the dominant language of Elis, Argos, Bœotia, and Attica, and even
at the present day a hundred thousand supposed Hellenes still speak
it. The actual population of Greece is, therefore, a very mixed one,
but it is difficult to say in what proportions these Hellenic, Slav, and
Albanian elements have combined. The Mainotes, or Maniotes, of
the peninsula terminating in Cape Matapan, are generally supposed
to be the Greeks of the purest blood. They themselves claim to be
the descendants of the ancient Spartans, and amongst their
strongholds they still point out one which belonged to “Signor
Lycurgus.” Their Councils of Elders have preserved from immemorial
times, and down to the war of independence, the title of Senate of
Lacedæmonia. Every Mainote professes to love unto death “Liberty,
the highest of all goods, inherited from our Spartan ancestors.”
Nevertheless, a good many localities in Maina bear names derived
from the Servian, and these prove, at all events, that the Slavs
resided in the country for a considerable time. The Mainotes practise
the vendetta , as if they were Montenegrins. But is not this a
common custom amongst all uncivilised nations?
However this may be, in spite of invasions and intermixture with
other races, the Greeks of to-day agree in most points with the
Greeks of the past. Above all things, they have preserved their
language, and it is truly matter for surprise that the vulgar Greek,
though derived from a rural dialect, should differ so slightly only
from the literary language. The differences, analogous to what may
be observed with respect to the languages derived from the Latin,
are restricted almost to two points, viz. the contraction of non-
accentuated syllables and the use of auxiliary verbs. It was,
therefore, easy for the modern Greeks to purify their language from
barbarisms and foreign terms, and to restore it gradually to what it
was in the time of Thucydides. Nor has the race changed much in its
physical features, for in most districts of modern Greece the ancient
types may yet be recognised. The Bœotian is still distinguished by
that heavy gait which made him an object of ridicule amongst the
other Greeks; the Athenian youth possesses the suppleness, grace of
movement and bearing which we admire so much in the horsemen
sculptured on the friezes of the Parthenon; the Spartan women have
preserved that haughty and vigorous beauty which constituted the
charm of the virgins of Doris. As regards morals, the descent of the
modern Hellenes is equally evident. Like their ancestors, they are
fond of change, and inquisitive; as the descendants of free citizens,
they have preserved a feeling of equality; and, still infatuated with
dialectics, they hold forth at all times as if they were in the ancient
market-place, or Agora. They frequently stoop to flattery: like the
ancient Greeks, too, they are apt to rate intellectual merit above
purity of morals. {44} Like sage Ulysses of the Homeric poem, they
well know how to lie and cheat with grace; and the truthful
Acarnanian and the Mainote, who are “slow to promise, but sure to
keep,” are looked upon as rural oddities. Another trait in the
character of the modern and ancient Greeks, and one which
distinguishes them from all other Europeans, is this—that they do
not allow themselves to be carried away by passion, except in the
cause of patriotism. The Greek is a stranger to melancholy: he loves
life, and is determined to enjoy it. In battle he may throw it away,
but suicide is a species of death unknown amongst the modern
Greeks, and the more unhappy they are, the more they cling to
existence. They are very seldom afflicted with insanity.
Fig. 10.—F OREIGN E LEMENTS IN THE P OPULATION OF G REECE. Μ

In spite of the diverse elements which compose it, the Greek


nationality is one of the most homogeneous in Europe. The
Albanians, of Pelasgian descent like the Greeks, do not cede to the
latter in patriotism; and it was they—the Suliotes, Hydriotes,
Spezziotes—who fought most valiantly for national independence.
The eight hundred families of Rumanian or Kutzo-Wallachian
Zinzares who pasture their herds in the hills of Acarnania and Ætolia,
and are known as Kara-Gunis, or “black cloaks,” speak the two
languages, and sometimes marry Greek girls, though they never give
their own daughters in marriage to the Greeks. Haughty and free,
they are not sufficiently numerous to be of any great importance. To
foreigners the Greeks are rather intolerant, and they take no pains to
render their stay amongst them agreeable. The Turks—who were
numerous formerly in certain parts of the Peloponnesus, in Bœotia,
and in the {45} island of Eubœa, and whose presence recalled an
unhappy period of servitude—have fled to a man, and only the fez,
the narghile, and the slippers remind us of their former presence.
The Jews, though met with in every town of the East, whether Slav
or Mussulman, dare hardly enter the presence of the Greeks, who
are, moreover, their most redoubtable rivals in matters of finance:
they are to be found only in the Ionian Islands, where they managed
to get a footing during the British Protectorate. In this same
Archipelago we likewise meet with the descendants of the ancient
Venetian colonists, and with emigrants from all parts of Italy. French
and Italian families still form a distinct element of the population of
Naxos, Santorin, and Syra. As to the Maltese porters and gardeners
at Athens and Corfu, they continue for the most part in subordinate
positions, and never associate with the Greeks.

The homogeneous character of the population of Greece does not


admit of that country being divided into ethnological provinces, like
Turkey or Austro-Hungary, but it consists geographically of four
distinct portions. These are (1), continental Hellas, known since the
Turkish invasion as Rumelia, in remembrance of the “Roman” empire
of Byzantium; (2), the ancient Peloponnesus, now called the Morea,
perhaps a transposition of the word “Romea,” or from a Slav word
signifying “sea coast,” and applied formerly to Elis; (3), the islands of
the Ægean Sea; (4), the Ionian Islands. In describing the various
portions of Greece we shall make use, in preference, of the ancient
names of mountains, rivers, and towns; for the Hellenes of our own
day, proud of the glories of the past, are endeavouring gradually to
get rid of names of Slav or Italian origin, which still figure upon the
13
maps of their country.
II.—C ONTINENTAL G REECE.
The Pindus, which forms the central chain of Southern Turkey,
passes over into Greece, and imparts to it an analogous orographical
character. On both sides of this conventional boundary we meet with
the same rocks, the same vegetation, the same landscape features,
and the same races of people. By dividing the Epirus and handing
over Thessaly to the Turks, European diplomacy has paid no
attention to natural features. The eastern portion of the boundary is
made to follow the line of water parting over the range of the lofty
Othrys, commanding the plain of the Sperchius. Westward of the
Pindus the boundary {46} crosses transversely the valley of the
Achelous, and the hills which separate it from the Gulf of Arta.
Fig. 11.—M OUNT P ARNASSUS AND D ELPHI.
The isolated summit of Mount Tymphrestus, or Velukhi, which
rises where the grand chain of the Othrys branches off from the
Pindus, is not the culminating point of continental Greece, but it is a
centre from which the principal mountain spurs and rivers radiate.
Within its spurs lies hidden the charming valley of Karpenisi, and an
elevated ridge joins them, towards the south-east, to the most
important mountain mass of modern Greece, viz. the group
surmounted by the snow-clad pyramids of the Vardusia and Khiona,
whose slopes are covered with dark firs, and to the superb
Katavothra, the Œta of the ancients, on which Hercules built his
funeral pile. The mountains of Vardusia and Khiona are face to face
with the fine mountain masses of Northern Morea, likewise wooded
and covered with snow during the greater part of the year.
The mountains of Ætolia, to the west of the Velukhi and the
Vardusia, are far less elevated, but they are rugged, and form a
veritable chaos of rocks, savage defiles, and thickets, into which only
Wallachian herdsmen venture. In Southern Ætolia, on the shores of
the lakes and along the rivers, the country is more accessible, but
mountains rise there likewise, and by tortuous ridges they are
brought into connection with the system of the Pindus. Those on the
coast of Acarnania, opposite to the Ionian Islands, are steep,
covered with trees and shrubs; they are the mountains of the “Black
Continent” mentioned by Ulysses. {47} To the east of the Achelous
there is another coast chain, well known to mariners: this is the
Zygos, the southern slopes of which, arid and austere, are seen from
off Missolonghi. Still further to the east another range comes down
to the seashore, and, together with the promontories on the
opposite coast of the Morea, forms the narrow entrance to the Gulf
of Corinth. Close to this entrance, on the Ætolian side, there rises
bold Mount Varassova, a huge block of rock. Local tradition tells us
that the Titans endeavoured to throw this rock into the sea, so that
it might form a bridge between the two coasts; but the rock proved
too heavy, and it was dropped where we now see it.
Towards the Ægean Sea the mountain mass of the Katavothra is
continued by a coast range running in a direction parallel to the
mountains of the island of Eubœa. This range should be described
rather as a series of mountain-groups separated from each other by
deep hollows, extensive depressions, and even by river valleys.
These mountains, though low and intersected by numerous roads,
are nevertheless difficult of access, for their slopes are steep, their
promontories abrupt, and their precipices sudden, and in the times
of the ancient Greeks a small number of men repeatedly defended
them against large armies. At one extremity of this range is the
passage of Thermopylæ; at the other, on the eastern foot of the
Pentelicus, the famous plain of Marathon.
The mountain groups on the northern shore of the Gulf of Corinth,
and to the south of Bœotia, may be looked upon as a range running
parallel with that following the channel of Eubœa, but far more
beautiful and picturesque. Every one of its summits recalls the sweet
memories of poetry, or conjures up the image of some ancient deity.
To the west we find ourselves in the presence of “double-headed”
Parnassus, to which fled Deucalion and Pyrrha, the ancestors of the
Greeks, and where the Athenians celebrated their torchlight dances
in honour of Bacchus. From the summits of the Parnassus, which
rival in height those of the Khiona, raising its pyramidal head
towards the north-west, nearly the whole of Greece, with its gulfs,
islands, and mountains, lies spread out below us, from the
Thessalian Olympus to the Taygetus, at the extremity of the
Peloponnesus; and close by, at our feet, lies the admirable basin of
Delphi, the place of Peace and Concord, where Greeks forgot their
animosities. The mountain group towards the east next to Parnassus
is quite equal to it. The valleys of the Helicon, the seat of Apollo and
the Muses, are still the most verdant and the most smiling in all
Greece. The eastern slope of the Helicon is more especially
distinguished for its charming beauty, its woods, its verdant
pastures, gardens, and murmuring springs, which contrast most
favourably with the bare and arid plains of Bœotia. If Mount
Parnassus may boast of the Castalian spring, Mount Helicon
possesses that of Hippocrene, which burst forth from the ground
when struck by the hoof of Pegasus. The elongated summit of the
Cithæron, the birthplace of Bacchus, joins the mountains of
Southern Bœotia to those of Attica, whose marble has become
famous through the neighbourhood of the city which they shelter.
Mount Parnes rises to the north of Athens; to the east of it, like the
pediment of a temple, rises the Pentelicus, in which are {48} the
quarries of Pikermi, rendered famous through their fossil bones; on
the south appears Mount Hymettus, celebrated for its flowers and its
bees. Farther away, the Laurium, with its rich argentiferous slags,
stretches towards the south-east, and terminates in Cape Sunium,
consecrated in other days to Minerva and Neptune, and still
surmounted by fifteen columns of an ancient temple.
Another isolated mountain group to the south of Attica, and
occupying the entire width of the Isthmus of Megara, served the
Athenians as a rampart of defence against their neighbours of the
Peloponnesus. This is the mountain group of Gerania, the modern
14
Pera Khora. Having passed beyond it, we find ourselves upon the
Isthmus of Corinth, properly so called, confined between the Gulfs of
Athens and of Corinth. It is a narrow neck of land, scarcely five miles
across, whose arid limestone rocks hardly rise two hundred feet
above the sea. This neutral bit of territory, lying between two distinct
geographical regions, naturally became a place for meetings,
festivals, and markets. The remains of a wall built by the
Peloponnesians across the isthmus may still be traced, as may also
the canal commenced by order of Nero.

The limestone mountains of Greece, as well as those of the Epirus


and of Thessaly, abound in lakes, but all the rivers are swallowed up
in “sinks,” or katavothras , leaving the land dry and arid. Southern
Acarnania, a portion of which is known as Xeromeros, or the “arid

You might also like