You are on page 1of 48

(eBook PDF) Starting Out with Java:

From Control Structures through Data


Structures 4th Edition
Visit to download the full and correct content document:
https://ebooksecure.com/download/ebook-pdf-starting-out-with-java-from-control-struc
tures-through-data-structures-4th-edition/
STARTING OUT WITH JAVA™
From Control Structures through Data Structures

FOURTH EDITION

Tony Gaddis

Haywood Community College

Godfrey Muganda

North Central College

330 Hudson Street, NY NY 10013


Senior Vice President Courseware Portfolio Management: Marcia J.
Horton

Director, Portfolio Management: Engineering, Computer Science & Global


Editions: Julian Partridge

Portfolio Manager: Matt Goldstein

Portfolio Management Assistant: Meghan Jacoby

Product Marketing Manager: Yvonne Vannatta

Field Marketing Manager: Demetrius Hall

Marketing Assistant: Jon Bryant

Managing Content Producer: Scott Disanno

Content Producer: Amanda Brands

Inventory Manager: Bruce Boundy

Manufacturing Buyer, Higher Ed, Lake Side Communications, Inc.


(LSC): Maura Zaldivar-Garcia

Cover Designer: Joyce Wells

Cover Image: phloen/Alamy Stock Photo

Manager, Rights Management: Ben Ferrini

Full-Service Project Management: Sasibalan Chidambaram, SPi Global

Composition: SPi Global

Cover Printer: Phoenix Color/Hagerstown

Printer/Bindery: LSC Communications, Inc.


Copyright © 2019, 2016, 2012, 2007 by Pearson Education, Inc. or its
affiliates. All Rights Reserved. Printed in the United States of America. This
publication is protected by copyright, and permission should be obtained
from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical,
photocopying, recording, or otherwise. For information regarding
permissions, request forms and the appropriate contacts within the Pearson
Education Global Rights & Permissions department, please visit
www.pearsoned.com/permissions/.

Many of the designations by manufacturers and sellers to distinguish their


products are claimed as trademarks. Where those designations appear in this
book, and the publisher was aware of a trademark claim, the designations
have been printed in initial caps or all caps.

Unless otherwise indicated herein, any third-party trademarks that may


appear in this work are the property of their respective owners and any
references to third-party trademarks, logos or other trade dress are for
demonstrative or descriptive purposes only. Such references are not intended
to imply any sponsorship, endorsement, authorization, or promotion of
Pearson’s products by the owners of such marks, or any relationship between
the owner and Pearson Education, Inc. or its affiliates, authors, licensees or
distributors.

Microsoft and/or its respective suppliers make no representations about the


suitability of the information contained in the documents and related graphics
published as part of the services for any purpose. All such documents and
related graphics are provided “as is” without warranty of any kind. Microsoft
and/or its respective suppliers hereby disclaim all warranties and conditions
with regard to this information, including all warranties and conditions of
merchantability. Whether express, implied or statutory, fitness for a particular
purpose, title and non-infringement. In no event shall microsoft and/or its
respective suppliers be liable for any special, indirect or consequential
damages or any damages whatsoever resulting from loss of use, data or
profits, whether in an action of contract. Negligence or other tortious action,
arising out of or in connection with the use or performance of information
available from the services.
The documents and related graphics contained herein could include technical
inaccuracies or typographical errors changes are periodically added to the
information herein. Microsoft and/or its respective suppliers may make
improvements and/or changes in the product(s) and/or the program(s)
described herein at any time partial screen shots may be viewed in full within
the software version specified.

Microsoft® Windows®, and Microsoft Office® are registered trademarks of


the Microsoft Corporation in the U.S.A. and other countries. This book is not
sponsored or endorsed by or affiliated with the Microsoft Corporation.

Oracle and Java are registered trademarks of Oracle and/or its affiliates.
Other names may be trademarks of their respective owners.

Library of Congress Cataloging-in-Publication Data

Names: Gaddis, Tony, author. | Muganda, Godfrey, author.

Title: Starting out with Java. From control structures through data structures /
Tony Gaddis, Haywood Community College, Godfrey Muganda, North
Central College.

Description: Fourth edition. | Pearson, [2019] | Includes bibliographical


references and index.

Identifiers: LCCN 2018002219| ISBN 9780134787961 | ISBN 013478796X

Subjects: LCSH: Java (Computer program language) | Data structures


(Computer science)

Classification: LCC QA76.73.J38 G33 2019 | DDC 005.13/3--dc23 LC


record available at https://lccn.loc.gov/2018002219

1 18
ISBN-13: 978-0-13-478796-1

ISBN-10: 0-13-478796-X
Contents in Brief
1. Chapter 1 Introduction to Computers and Java 1

2. Chapter 2 Java Fundamentals 27

3. Chapter 3 Decision Structures 111

4. Chapter 4 Loops and Files 189

5. Chapter 5 Methods 269

6. Chapter 6 A First Look at Classes 317

7. Chapter 7 Arrays and the ArrayList Class 403

8. Chapter 8 A Second Look at Classes and Objects 493

9. Chapter 9 Text Processing and More about Wrapper Classes 557

10. Chapter 10 Inheritance 611

11. Chapter 11 Exceptions and Advanced File I/O 701

12. Chapter 12 JavaFX: GUI Programming and Basic Controls 759

13. Chapter 13 JavaFX: Advanced Controls 823

14. Chapter 14 JavaFX: Graphics, Effects, and Media 909

15. Chapter 15 Recursion 999

16. Chapter 16 Sorting, Searching, and Algorithm Analysis 1027

17. Chapter 17 Generics 1079

18. Chapter 18 Collections and the Stream API 1125


19. Chapter 19 Linked Lists 1195

20. Chapter 20 Stacks and Queues 1245

21. Chapter 21 Binary Trees, AVL Trees, and Priority Queues 1287

1. Index 1353

2. Appendices A–M Companion Website

3. Chapters 22–25 Companion Website

4. Case Studies 1–7 Companion Website


Contents
1. Preface xxv

1. Chapter 1 Introduction to Computers and Java 1

1. 1.1 Introduction 1

2. 1.2 Why Program? 1

3. 1.3 Computer Systems: Hardware and Software 2

1. Hardware 2

2. Software 5

4. 1.4 Programming Languages 6

1. What Is a Program? 6

2. A History of Java 8

5. 1.5 What Is a Program Made Of? 8

1. Language Elements 8

2. Lines and Statements 11

3. Variables 11

4. The Compiler and the Java Virtual Machine 12

5. Java Software Editions 13

6. Compiling and Running a Java Program 14

6. 1.6 The Programming Process 16


1. Software Engineering 18

7. 1.7 Object-Oriented Programming 19

1. Review Questions and Exercises 21

2. Programming Challenge 25

2. Chapter 2 Java Fundamentals 27

1. 2.1 The Parts of a Java Program 27

2. 2.2 The print and println Methods, and the Java API 33

3. 2.3 Variables and Literals 39

1. Displaying Multiple Items with the + Operator 40

2. Be Careful with Quotation Marks 41

3. More about Literals 42

4. Identifiers 42

5. Class Names 44

4. 2.4 Primitive Data Types 44

1. The Integer Data Types 46

2. Floating-Point Data Types 47

3. The boolean Data Type 50

4. The char Data Type 50

5. Variable Assignment and Initialization 52

6. Variables Hold Only One Value at a Time 53


5. 2.5 Arithmetic Operators 54

1. Integer Division 57

2. Operator Precedence 57

3. Grouping with Parentheses 59

4. The Math Class 62

6. 2.6 Combined Assignment Operators 63

7. 2.7 Conversion between Primitive Data Types 65

1. Mixed Integer Operations 67

2. Other Mixed Mathematical Expressions 68

8. 2.8 Creating Named Constants with final 69

9. 2.9 The String Class 70

1. Objects Are Created from Classes 71

2. The String Class 71

3. Primitive Type Variables and Class Type Variables 71

4. Creating a String Object 72

10. 2.10 Scope 76

11. 2.11 Comments 78

12. 2.12 Programming Style 83

13. 2.13 Reading Keyboard Input 85

1. Reading a Character 89
2. Mixing Calls to nextLine with Calls to Other Scanner
Methods 89

14. 2.14 Dialog Boxes 93

1. Displaying Message Dialogs 93

2. Displaying Input Dialogs 94

3. An Example Program 94

4. Converting String Input to Numbers 96

15. 2.15 Common Errors to Avoid 99

1. Review Questions and Exercises 100

2. Programming Challenges 106

3. Chapter 3 Decision Structures 111

1. 3.1 The if Statement 111

1. Using Relational Operators to Form Conditions 113

2. Putting It All Together 114

3. Programming Style and the if Statement 117

4. Be Careful with Semicolons 117

5. Having Multiple Conditionally Executed Statements 118

6. Flags 118

7. Comparing Characters 119

2. 3.2 The if-else Statement 121

3. 3.3 Nested if Statements 124


4. 3.4 The if-else-if Statement 128

5. 3.5 Logical Operators 134

1. The Precedence of Logical Operators 139

2. Checking Numeric Ranges with Logical Operators 140

6. 3.6 Comparing String Objects 142

1. Ignoring Case in String Comparisons 146

7. 3.7 More about Variable Declaration and Scope 147

8. 3.8 The Conditional Operator (Optional) 149

9. 3.9 The switch Statement 150

10. 3.10 Displaying Formatted Output with System.out.printf and


String.format 160

1. Format Specifier Syntax 163

2. Precision 164

3. Specifying a Minimum Field Width 164

4. Flags 167

5. Formatting String Arguments 170

6. The String.format Method 172

11. 3.11 Common Errors to Avoid 174

1. Review Questions and Exercises 175

2. Programming Challenges 181

4. Chapter 4 Loops and Files 189


1. 4.1 The Increment and Decrement Operators 189

1. The Difference between Postfix and Prefix Modes 192

2. 4.2 The while Loop 193

1. The while Loop Is a Pretest Loop 196

2. Infinite Loops 196

3. Don’t Forget the Braces with a Block of Statements 197

4. Programming Style and the while Loop 198

3. 4.3 Using the while Loop for Input Validation 200

4. 4.4 The do-while Loop 204

5. 4.5 The for Loop 207

1. The for Loop Is a Pretest Loop 210

2. Avoid Modifying the Control Variable in the Body of the for


Loop 211

3. Other Forms of the Update Expression 211

4. Declaring a Variable in the for Loop’s Initialization


Expression 211

5. Creating a User Controlled for Loop 212

6. Using Multiple Statements in the Initialization and Update


Expressions 213

6. 4.6 Running Totals and Sentinel Values 216

1. Using a Sentinel Value 219


7. 4.7 Nested Loops 221

8. 4.8 The break and continue Statements (Optional) 229

9. 4.9 Deciding Which Loop to Use 229

10. 4.10 Introduction to File Input and Output 230

1. Using the PrintWriter Class to Write Data to a File 230

2. Appending Data to a File 236

3. Specifying the File Location 237

4. Reading Data from a File 237

5. Reading Lines from a File with the nextLine Method 238

6. Adding a throws Clause to the Method Header 241

7. Checking for a File’s Existence 245

11. 4.11 Generating Random Numbers with the Random Class 249

12. 4.12 Common Errors to Avoid 255

1. Review Questions and Exercises 256

2. Programming Challenges 262

5. Chapter 5 Methods 269

1. 5.1 Introduction to Methods 269

1. void Methods and Value-Returning Methods 270

2. Defining a void Method 271

3. Calling a Method 272


4. Layered Method Calls 276

5. Using Documentation Comments with Methods 277

2. 5.2 Passing Arguments to a Method 279

1. Argument and Parameter Data Type Compatibility 281

2. Parameter Variable Scope 282

3. Passing Multiple Arguments 282

4. Arguments Are Passed by Value 284

5. Passing Object References to a Method 285

6. Using the @param Tag in Documentation Comments 288

3. 5.3 More about Local Variables 290

1. Local Variable Lifetime 292

2. Initializing Local Variables with Parameter Values 292

4. 5.4 Returning a Value from a Method 293

1. Defining a Value-Returning Method 293

2. Calling a Value-Returning Method 294

3. Using the @return Tag in Documentation Comments 296

4. Returning a boolean Value 300

5. Returning a Reference to an Object 300

5. 5.5 Problem Solving with Methods 302

1. Calling Methods That Throw Exceptions 305


6. 5.6 Common Errors to Avoid 305

1. Review Questions and Exercises 306

2. Programming Challenges 311

6. Chapter 6 A First Look at Classes 317

1. 6.1 Objects and Classes 317

1. Classes: Where Objects Come From 318

2. Classes in the Java API 319

3. Primitive Variables vs. Objects 321

2. 6.2 Writing a Simple Class, Step by Step 324

1. Accessor and Mutator Methods 338

2. The Importance of Data Hiding 338

3. Avoiding Stale Data 339

4. Showing Access Specification in UML Diagrams 339

5. Data Type and Parameter Notation in UML Diagrams 339

6. Layout of Class Members 340

3. 6.3 Instance Fields and Methods 341

4. 6.4 Constructors 346

1. Showing Constructors in a UML Diagram 348

2. Uninitialized Local Reference Variables 348

3. The Default Constructor 348


4. Writing Your Own No-Arg Constructor 349

5. The String Class Constructor 350

5. 6.5 Passing Objects as Arguments 358

6. 6.6 Overloading Methods and Constructors 370

1. The BankAccount Class 372

2. Overloaded Methods Make Classes More Useful 378

7. 6.7 Scope of Instance Fields 378

1. Shadowing 379

8. 6.8 Packages and import Statements 380

1. Explicit and Wildcard import Statements 380

2. The java.lang Package 381

3. Other API Packages 381

9. 6.9 Focus on Object-Oriented Design: Finding the Classes and


Their Responsibilities 382

1. Finding the Classes 382

2. Identifying a Class’s Responsibilities 385

3. This Is Only the Beginning 388

10. 6.10 Common Errors to Avoid 388

1. Review Questions and Exercises 389

2. Programming Challenges 394

7. Chapter 7 Arrays and the ArrayList Class 403


1. 7.1 Introduction to Arrays 403

1. Accessing Array Elements 405

2. Inputting and Outputting Array Contents 406

3. Java Performs Bounds Checking 409

4. Watch Out for Off-by-One Errors 410

5. Array Initialization 411

6. Alternate Array Declaration Notation 412

2. 7.2 Processing Array Elements 413

1. Array Length 415

2. The Enhanced for Loop 416

3. Letting the User Specify an Array’s Size 417

4. Reassigning Array Reference Variables 419

5. Copying Arrays 420

3. 7.3 Passing Arrays as Arguments to Methods 422

4. 7.4 Some Useful Array Algorithms and Operations

1. Comparing Arrays 426

2. Summing the Values in a Numeric Array 427

3. Getting the Average of the Values in a Numeric Array 428

4. Finding the Highest and Lowest Values in a Numeric Array


428

5. The SalesData Class 429


6. Partially Filled Arrays 437

7. Working with Arrays and Files 438

5. 7.5 Returning Arrays from Methods 439

6. 7.6 String Arrays 441

1. Calling String Methods from an Array Element 443

7. 7.7 Arrays of Objects 444

8. 7.8 The Sequential Search Algorithm 447

9. 7.9 Two-Dimensional Arrays 450

1. Initializing a Two-Dimensional Array 454

2. The length Field in a Two-Dimensional Array 455

3. Displaying All the Elements of a Two-Dimensional Array 457

4. Summing All the Elements of a Two-Dimensional Array 457

5. Summing the Rows of a Two-Dimensional Array 458

6. Summing the Columns of a Two-Dimensional Array 458

7. Passing Two-Dimensional Arrays to Methods 459

8. Ragged Arrays 461

10. 7.10 Arrays with Three or More Dimensions 462

11. 7.11 The Selection Sort and the Binary Search Algorithms 463

1. The Selection Sort Algorithm 463

2. The Binary Search Algorithm 466


12. 7.12 Command-Line Arguments and Variable-Length Argument
Lists 468

1. Command-Line Arguments 469

2. Variable-Length Argument Lists 470

13. 7.13 The ArrayList Class 472

1. Creating and Using an ArrayList Object 473

2. Using the Enhanced for Loop with an ArrayList 474

3. The ArrayList Class’s toString method 475

4. Removing an Item from an ArrayList 476

5. Inserting an Item 477

6. Replacing an Item 478

7. Capacity 479

8. Storing Your Own Objects in an ArrayList 479

9. Using the Diamond Operator for Type Inference 480

14. 7.14 Common Errors to Avoid 481

1. Review Questions and Exercises 481

2. Programming Challenges 486

8. Chapter 8 A Second Look at Classes and Objects 493

1. 8.1 Static Class Members 493

1. A Quick Review of Instance Fields and Instance Methods 493

2. Static Members 494


3. Static Fields 494

4. Static Methods 497

2. 8.2 Passing Objects as Arguments to Methods 500

3. 8.3 Returning Objects from Methods 503

4. 8.4 The toString Method 505

5. 8.5 Writing an equals Method 509

6. 8.6 Methods That Copy Objects 512

1. Copy Constructors 514

7. 8.7 Aggregation 515

1. Aggregation in UML Diagrams 523

2. Security Issues with Aggregate Classes 523

3. Avoid Using null References 525

8. 8.8 The this Reference Variable 528

1. Using this to Overcome Shadowing 529

2. Using this to Call an Overloaded Constructor from Another


Constructor 530

9. 8.9 Enumerated Types 531

1. Enumerated Types Are Specialized Classes 532

2. Switching On an Enumerated Type 538

10. 8.10 Garbage Collection 540

1. The finalize Method 542


11. 8.11 Focus on Object-Oriented Design: Class Collaboration 542

1. Determining Class Collaborations with CRC Cards 545

12. 8.12 Common Errors to Avoid 546

1. Review Questions and Exercises 547

2. Programming Challenges 551

9. Chapter 9 Text Processing and More about Wrapper Classes 557

1. 9.1 Introduction to Wrapper Classes 557

2. 9.2 Character Testing and Conversion with the Character Class


558

1. Character Case Conversion 563

3. 9.3 More String Methods 566

1. Searching for Substrings 566

2. Extracting Substrings 572

3. Methods That Return a Modified String 576

4. The Static valueOf Methods 577

4. 9.4 The StringBuilder Class 579

1. The StringBuilder Constructors 580

2. Other StringBuilder Methods 581

3. The toString Method 584

5. 9.5 Tokenizing Strings 589

6. 9.6 Wrapper Classes for the Numeric Data Types 594


1. The Static toString Methods 594

2. The toBinaryString, toHexString, and toOctalString


Methods 594

3. The MIN_VALUE and MAX_VALUE Constants 595

4. Autoboxing and Unboxing 595

7. 9.7 Focus on Problem Solving: The TestScoreReader Class 597

8. 9.8 Common Errors to Avoid 601

1. Review Questions and Exercises 601

2. Programming Challenges 605

10. Chapter 10 Inheritance 611

1. 10.1 What Is Inheritance? 611

1. Generalization and Specialization 611

2. Inheritance and the “Is a” Relationship 612

3. Inheritance in UML Diagrams 620

4. The Superclass’s Constructor 621

5. Inheritance Does Not Work in Reverse 623

2. 10.2 Calling the Superclass Constructor 624

1. When the Superclass Has No Default or No-Arg Constructors


630

2. Summary of Constructor Issues in Inheritance 631

3. 10.3 Overriding Superclass Methods 632


Another random document with
no related content on Scribd:
He kin’ o’ l’itered on the mat,
Some doubtfle o’ the sekle;
His heart kept goin’ pity-pat,
But hern went pity Zekle.

An’ yit she gin her cheer a jerk


Ez though she wished him furder,
An’ on her apples kep’ to work,
Parin’ away like murder.

“You want to see my Pa, I s’pose?”


“Wal ... no ... I come designin’”—
“To see my Ma? She’s sprinklin’ clo’es
Agin to-morrer’s i’nin’.”

To say why gals act so or so,


Or don’t, ’ould be presumin’;
Mebby to mean yes an’ say no
Comes nateral to women.

He stood a spell on one foot fust,


Then stood a spell on t’other,
An’ on which one he felt the wust
He couldn’t ha’ told ye nuther.

Says he, “I’d better call agin;”


Says she, “Think likely, Mister”;
Thet last word pricked him like a pin,
An’ ... Wal, he up an’ kist her.

When Ma bimeby upon ’em slips,


Huldy sot pale as ashes,
All kin’ o’ smily roun’ the lips
An’ teary roun’ the lashes.

For she was jes’ the quiet kind


Whose naturs never vary,
Like streams that keep a summer mind
Snowhid in Jenooary.

The blood clost roun’ her heart felt glued


Too tight for all expressin’,
Tell mother see how matters stood,
An’ gin ’em both her blessin’.

Then her red come back like the tide


Down to the Bay o’ Fundy,
An’ all I know is they was cried
In meetin’ come next Sunday.

A RAINY DAY
By Ellye Howell Glover

I simply cannot understand


Why grown-ups always say,
“Don’t spend your money, little boy;
Save for a rainy day.”

Once, when the circus was in town


I asked Bob for a quarter;
He said, “You’re so extravagant,
For shame; I think you’d oughter—

“Save all your pennies; after while


You’ll need them, silly baby;
For if you spend them all, you’ll go
Out to the poorhouse—maybe.”

And so I waited till next time


When it rained cats and dogs;
I took the big umbrella, and
Put on my oldest togs.

And when they stopped me with the words


I knew of course they’d say,
I hollered, “I must spend my dime,
Cause it’s a rainy day.”

SCHOOL’S COMMENCED
By Leonard G. Nattkemper

Well, I guess I’ll have to go—


For school’s commenced again, you know;
An’ now I’ll have to be polite,
An’ watch my words wif all my might.

I wish the school ’ud blow away,


Or teachers all were sick to-day;
For nen I’d be just what I am,
An’ play all day wif Jake an’ Sam.

I guess us boys ’ud ruther be


The pirates on a stormy sea,
That shoot wif guns an’ cut wif knives,
Than spend in school most all our lives.

I can’t see why Ma thinks ’at school


Is better place than swimmin’ pool;
Or that I’ll learn more in a book
Than from my pal, the flowin’ brook.

It may be so, but I don’t care,


I’d ruther be a-dreamin’ there
How fine it is to be like men,
An’ never go to school again.

My Ma an’ Pa both said that they


Would be so glad when I’m away;
An’ so, I guess I’ll have to go—
For school’s commenced again, you know.
UNDERSTAENDLICH
By Edmund Vance Cooke
(ABRIDGED)

Dhe contrariest t’ing on dhe erd is men,


Aber wimmens arr twice so contrary again,
Andt I am twice so contrary as you,
Andt you arr as worse as dhe worst one too;
Now, ain’d dhat zo?

You like to haf hoonger by dinner, you say,


Aber vhy do you eadt, so dat hoonger go ’vay?
You like to be tired, so you schleep like a top,
Andt you like to go schleep, so dhat tired feeling shtop;
Now, ain’d dhat zo?

You like to haf sugar on sauer t’ings you eadt


Andt you like to haf sauer mit dhe t’ings vhat arr sweet,
You like to be cold when dhe vetter is hot;
Andt it is cold, ach, how varm you vould got!
Now, aindt dhat zo?

How you shdare at dhe man vhat can valk up dhe street
On his hands, yet you valk twice so goodt on your feet,
Vhat a long mind you haf, if I’m in your debt,
Budt if you arr in mine, O, how quick you forget!
Now, aindt dhat zo?

Are you single? You like to be married, of course.


Are you married? Most likely you like a divorse!
Andt if you vas get unmarried, why dhen
You go righd avay and got married again.
Now, ain’d dhat zo?

It is bedter to laugh; it is foolish to fight


Yoost because I am wrong and because you ain’d right,
It is better to laugh mit dhe vorld, up and down
From dhe sole of our headt to the foot of our crown;
Now, ain’d dhat zo?

Zo, dhen you laugh at me andt dhen I laugh at you,


Andt dhe more dhat you laugh vhy dhe more I laugh, too,
Andt ve laugh till ve cry! Vhen ve cry, aber dhen,
Ve will bot’ feel zo goot ve go laughing again!
Now, ain’d dhat zo?

A THURRU’ REST
Anonymous

Examination’s over ’n’ I don’t care if I passed,


An’ I don’t care if I didn’t fer vacation’s come at last!
I thought ’twould never git here, fer the days dragged by as slow
As Davy Jones’s ma, who calls ’n’ don’t know when to go.
Pop says I ort to go to work, but ma says she knows best,
’N’ what a boy of my age needs is just a thurru’ rest.

So me an’ Dave’ll get up every mornin’ bright ’n’ soon,


An’ pitch ’n’ ketch till breakfast, ’n’ bat up flies till noon.
’Cause after dinner every day the Hustlehards—his nine—
Is goin’ to play a series fer the champeenship with mine:
The one behind at dark has got to say the other’s best.
Gee! ain’t I glad vacation’s here ’n’ I got time to rest.

Then I’m a-goin’ to learn the other fellers how to dive,


An’ rassle Billy Potter, best thirteen in twenty-five!
’N’ after supper Dave ’n’ I are goin’ to have a race,
Ten times around the block, ’n’ if I win he’ll bust my face.
That’s what he says! But he’ll find out which one of us is best;
I’m feeling pretty strong now since I’m havin’ such a rest.

There’s goin’ to be a picnic ’n’ you bet yer life I’m goin’;
I’m entered in the swimmin’ race, ’n’ greasy pole, ’n’ rowin’,
The sack race ’n’ potato race are mine, I bet a dime,
’N’ in “the mile” I simply got to win the prize fer time,
’Cause it’s a ticket to the Gym. I like that prize the best,
Fer a feller needs some exercise as well as just a rest.

I’m goin’ to visit Uncle’s farm. He lets me do the chores


’N’ work just like the farm-hands do, right in the fields out-doors.
I’m goin’ to git a bag to punch, so’s I won’t git too fat:
We’re goin’ to have a six-day race—I got to train fer that.
I want to do so many things, I don’t know which is best;
I bet vacation’s over ’fore I get a thurru’ rest!

NO SHOOTIN’ OFF THIS YEAR


Anonymous

There ain’t no Declaration. Naw


There ain’t no Fourth-July.
There ain’t no “free ’n’ equal” law,
’N’ Washin’ton could lie.
They never dumped no Boston tea;
It’s fakey, all you hear,
Fer pop says there ain’t goin’ to be
No shootin’ off this year.

They talk about pertectin’ us


To keep the Fourth in peace;
But we ain’t makin’ any fuss,
Ner askin’ fer police.
We ain’t afraid of smoke ’n’ noise,
Er little lumps of lead;
’N’ why should they blame livin’ boys
Because some boys is dead?

It ain’t my fault the fuse went out


’N’ Tom went up ’n’ blew;
Besides he’s just as well without
His extry ear er two.
They cut off Oscar’s leg, but he
Don’t seem to miss it much;
He’d beat us hoppin’ yet, if we
’Ud let him use his crutch.

It ain’t my fault that Willie blew


His hand off, like a chump;
I told him what those big ones do;
He needn’t ’a’ took the stump.
It ain’t my fault a rocket flies
’N’ hits some him er her;
Somebody’s got to wear glass eyes;
That’s what glass eyes is fer!

It ain’t my fault the stuff was bad


They made Jim’s pistol of;
Besides the preacher said, “We’re glad
He’s happier up above!”
Bet I’d be happier, anyhow,
Most any place but here,
Where they ain’t goin’ to allow
No shootin’ off this year!

HAUL AWAY, JOE


By Charles Keeler

O Oi wuz a loafin’ lubber but bedad I learned to wurrk


Whin Oi loighted out o’ County Corrk along wid Paddy Burrke.
We stowed abarrd a coaster an’ her skipper wuz a brick;
Begorrah if yez didn’t moind, he’d boost yez wid a kick!
Away, haal away, haal away, Joe!

Th’ pigs wuz lane in County Corrk, th’ men all starrved on taties,
But Oi shipped upon a Yankee barrk, and better, faith, me fate is!
Och Oi hed an Irish darlint, but she ghrew so fat an’ lazy
Thet Oi bounced her fur a Yankee gurrl, an’ surre but she’s a daisy!
Away, haal away, haal away, Joe!
O since Oi lift auld Ireland Oi’ve poaked thro’ miny plaices,
Oi’ve wurrked me way, Oi’ve arrned me pay at haalin’ shates an’
braces;
On farrin’ shorres Oi’ve sot me eye on gurrls iv iv’ry nashin,
Me Yankee gurrl hes ne’er a mate throughhout th’ woid creashin!
Away, haal away, haal away, Joe!

—Copyright by the publisher, A. M. Robertson, San Francisco, and


used by his kind permission.

BLACK SAILORS’ CHANTY


By Charles Keeler

Yo ho, ma hahties, da’s a hurricane a-brewin’,


Fo’ de cook he hasn’t nuffin fo’ de sailah-men a-stewin’,—
He am skulkin’ in his bunk, am dat niggah of a cook,
An’ his chaowdah ’m in de ocean while de pot am on de hook.
You can chaw a chunk o’ hahd-tack mos’ as tendah as a brick,
But d’ain’t no smokin’ ’possum when de cook am lyin’ sick.

Ah remembah in de cane-fiel’ we hed pone-cakes ebry day;


Slack yo line a bit, ma hahties! pull away! pull away!
An’ Ah ’low Ah’m feelin’ homesick, jes’ t’ mention ob ma honey,—
She’s a libbin’ at de cabin an’ she’s out o’ cloes an’ money.
While we chaw a chunk o’ hahd-tack mos’ as tendah as a brick,
But d’ain’t no smokin’ ’possum while de cook am lyin’ sick.

O ma po’ neglected Liza an’ her piccaninny Jo,


Ah’s ben roamin’ sence Ah left her case Ah wanted fo’ to go!
Ah’s ben hustlin’ roun’ de islands, navigatin’ all de sea,
While ma honey specs a hungry shark done stuff hisself wid me.
While we chaw a chunk o’ hahd-tack mos’ as tendah as a brick,
But d’ain’t no smokin’ ’possum while de cook am lyin’ sick.

—Copyright by the publisher, A. M. Robertson, San Francisco; and


used by his kind permission.
JOSIAH AND SYMANTHY
By Fred Emerson Brooks

Josiah loved Symanthy


And Symanthy loved Josi’,
Which you couldn’t fail to notice
In the rollin’ of the eye;
But they never told each other,
On account o’ bein’ shy,
’Pears to me!

But they kept right on a-lovin’


Jes like any couple would.
Weren’t no reason why they shouldn’t,
Ner no reason why they should,
’Cause there wa’n’t no p’ints about ’em
Cupid reckoned on as good,
’Pears to me!

Now this love disease is mortal,


’Cause it tackles mortals so,
An’ the oftener you have it
The worse it seems to grow;
More you try to hide the symptoms,
More the symptoms seem to show,
’Pears to me!

Josiah was uneasy


When Symanthy wasn’t near,
An’ he got still more uneasy
Whenever she’d appear.
But sittin’ down beside ’er
Got his joints clean out o’ gear,
’Pears to me!

He put his arm behind ’er,


An’ then he pulled it back
Until Symanthy giggled:
“Guess yer gittin’ on the track
By the way yer flusticatin’;
Kind a-lookin’ fer a smack,
’Pears to me!”

Then Josiah stopped a minute,


Jes consid’rin’ how ’twould be
An’ how best to go about it,
’Cause he hadn’t much idee;
But he knew ’twas waitin’ fer him,
By Symanthy’s shy te-he!
’Pears to me!

Then Symanthy got pretending,


She was bitin’ off her thumb,
But she wasn’t—she was waitin’
For whatever chose to come;
While Josiah’s tongue kept rollin’
In his cheek, like chewin’-gum,
’Pears to me!

When Josiah was persuaded


That Symanthy wouldn’t shout,
Wa’n’t a-jokin’, ner a-foolin’,
Ner a-fixin’ to back out,—
Then he buckled up his courage:
Kissed her cheek or thereabout,
’Pears to me!

Then he asked ’er if she’d have him,


An’ she answered: “What d’ ye guess?”
Said he wa’n’t no good at guessin’;
So she smiled an’ snickered: “Yes!
Since I git ye all fer nothin’
I couldn’t do no less,
’Pears to me!”
When the Squire asked ’em the questions—
On the weddin’-day they set—
Which some people answer quickly
An’ about as soon forget,—
Symanthy said: “I reckin!”
An’ Josiah said: “You bet!”
’Pears to me!

When they took their weddin’ journey


Up an’ down the city street,
Josiah told Symanthy
That he guessed they’d have a treat:
So they went an’ got some oysters—
What they never yet had eat,
’Pears to me!

Then Josiah, sort o’ thinkin’,


Said: “I thought they had a shell;
What the slipp’ry things resemble
I’ll be switched if I can tell;
An’ they look so pale an’ sickly
Kind o’ reckon they ain’t well,
’Pears to me!”

“I wonder how they eat ’em?”


Said Symanthy, “How’d I know?
I’ve eat everythin’ that you have
Ever since you’ve been my beau!
But I’ll bet a cent ye dasn’t
Put one in an’ let ’er go!
’Pears to me!”

While Symanthy eat the crackers


Josiah let one slip;
Said it didn’t taste like nothin’;
Wasn’t ripe; then closed his lip;
Vowed he wouldn’t eat another,
Fear ’twould spile his weddin’ trip,
’Pears to me!

When the tip-expectin’ beggar


Bowed, an’ smilin’ meekly, said:
“Colonel hasn’t feed the waitah!”
Then Josiah jerked his head—
“You can feed on them ’ere oysters
If the pesky things ain’t dead,
’Pears to me!”

—Copyright by Forbes & Co., Chicago, and used by kind


permission of author and publisher.

CHARLIE JONES’S BAD LUCK


By A. J. Waterhouse
(As discussed by little Willie)

I don’t care if Charlie Jones


Is better ’an I be;
An’ I don’t care if teacher says
He’s smart ’long side er me;
An’ I don’t care, w’en vis’tors come,
If she on him does call;
He ain’t got measles, like I have—
He don’t have luck at all.

He never had the whoopin’ cough,


Ner mos’ cut off his thumb,
Ner ever fell an’ broke his leg
An’ had a doctor come.
He hardly ever stubs his toe,
An’ if he does, he’ll bawl!
There’s nothin’ special comes to him—
He don’t have luck at all.

An’ I don’t care if he can say


More tex’s an’ things ’an I;
He never burnt both hands to once
’Long ’bout the Fo’th July.
He never had the chicken-pox,
Ner p’isen oak—las’ Fall!
He can’t be proud o’ nothin’ much—
He don’t have luck at all.

—From “Lays for Little Chaps.”

KISSING’S NO SIN
Anonymous

Some say that kissing’s a sin;


But I think it’s nane ava,
For kissing has wonn’d in this warld
Since ever that there was twa.

O, if it wasna lawfu’,
Lawyers wadna allow it;
If it wasna holy,
Ministers wadna do it.

If it wasna modest,
Maidens wadna take it;
If it wasna plenty,
Puir folks wadna get it.

IF I DARST
By Eugene Field

I’d like to be a cowboy, an’ ride a firey hoss


Way out into the big and boundless West;
I’d kill the bears an’ catamounts an’ wolves I come across,
An’ I’d pluck the bal’ head eagle from his nest!
With my pistol at my side,
I would roam the prarers wide,
An’ to scalp the savage Injun in his wigwam would I ride—
If I darst; but I darsen’t.

I’d like to go to Afriky an’ hunt the lions there,


An’ the biggest ollyfunts you ever saw!
I would track the fierce gorilla to his equatorial lair,
An’ beard the cannybull that eats folks raw.

I’d chase the pizen snakes


An’ the pottimus that makes
His nest down at the bottom of unfathomable lakes—
If I darst; but I darsen’t.

I would I were a pirut to sail the ocean blue,


With a big black flag a-flyin’ overhead;
I would scour the billowy main with my gallant pirut crew,
An’ dye the sea a gouty, gory red.

With my cutlass in my hand


On the quarterdeck I’d stand
And to deeds of heroism I’d incite my pirut band—
If I darst; but I darsen’t.

And, if I darst, I’d lick my pa for the times that he’s licked me,
I’d lick my brother an’ my teacher, too,
I’d lick the fellers that call round on sister after tea,
An’ I’d keep on lickin’ folks till I got through.

You bet. I’d run away


From my lessons to my play,
An’ I’d shoo the hens, and tease the cat, an’ kiss the girls all day—
If I darst; but I darsen’t.

DERNDEST GAL I EVER KNOWED


By Herbert Bashford
Derndest gal I ever knowed,
Neatest gal I ever seen,
Lived down in the Red Ravine
Jest below the county road,
Guess she wuz about sixteen—
Sophy wuz her name, an’ she
Wuz ez cute ez cute kin be.

When I’d go t’ town I brung


Her the biggest lot o’ stuff,
Pop-corn, likrish, ’n’ enough
Candy fer t’ fill a room.
Once she hit me with a broom
Cuz I kissed her on the cheek,
An’ the midget wouldn’t speak
T’ me fer, perhaps, a week.

When I’d raise my eyes to hern


Jeminny! my cheeks ’ud burn
An’ git redder ’n’ a beet.
Oh, she looked jest powerful sweet!
When I’d try to call her dear,
Why, I’d feel so doggoned queer
That I’d lean ag’in’ th’ fence
’Zif I didn’ hev no sense,
Twist th’ buttons on my vest,
Ast her who she liked th’ best,
Ast her if it wuzn’t Bill,
Er old Jones thet run th’ mill,
Keep a-hintin’ ’round, yuh see,
Till she’d up an’ say ’twuz me.

I wuz jellus o’ Jim Pike,


Jellus ez th’ very deuce
Though there didn’t seem much use,
Fer his freckles wuz so thick,
An’ his hair wuz so like brick
Thet a feller one day said
Yuh could toast a hunk o’ bread
Ef yuh’d hold it nigh his head.
He wuz awkarder’n sin,
Never fished along the crick
But he’d hev t’ tumble in.

Sophy ’peared t’ pity Jim,


While I thought if I wuz him
I’d go off ’n’ hide somewhere,
Else put plaster on my hair.
But this homely, lantern-jawed
Lookin’ cuss stood ’round ’n’ chawed
On a plug o’ terbacker
Half his time ’n’ talked t’ her
Of his love, till I jest told
Him t’ mosey, an’ he rolled
Up his sleeves ’n’ landed me
Plumb betwixt th’ eyes, then he
Went to Sophy, an’, sir, she
Married him! The pesky mule!
Wuzn’t she a reg’ler fool?
I wuz jest tetotally blowed—
Derndest gal I ever knowed!

—Copyright by Harr Wagner Co., San Francisco, and used by kind


permission of author and publisher.

ON NEWBRASKY’S FERTILE SHORE


By Herbert Bashford

Oh, I am so orful humsick! An’ I feel so wretched queer!


Ephrum, he has gone a-ridin’ on a wild eclectric keer,
Rhody—that’s my only darter—she has gone an’ left me, tew,
Both a trapesin’ ’round like ijits—wonder what’s th’ next they’ll do?
They don’t seem to think they’re darin’ Providence right in th’ face,
Ridin’ without hoss er engine ’n’ goin’ at a break-neck pace:
Course I needn’t stand here waitin’, both insisted I should come,
But I vow I’ll not be reckless when I am so fer from hum:
Clear out here by th’ Pacific, jist as fur as we kin git,
An’ if we stay here much longer I declare I’ll hev a fit.
It’s th’ most deceivin’ kentry as ever’ one’ll say
Ever’ drap o’ water salty in th’ hull o’ Frisco bay.
Oh, I’ve tramped these pesky sidewalks till my feet is lame an’ sore,
An’ a-yearnin’ ever’ minute fur Newbrasky’s fertile shore!

Then they brag about their scenery! Californy! Humph! O dear!


Scenery! Well, jest speaking plainly, I don’t see no scenery here:
Nothin’ but the mount’in ranges rarin’ up so ’tarnal high
Thet a buddy kint look nowheres ’cept the middle o’ th’ sky.
Mount’ins, everlastin’ mount’ins, hills ’n’ woods ’n’ rocks ’n’ snow,
Where th’ scenery is they’re braggin’ on I’m th’ one as wants t’ know.
Let ’em stand in Lincoln county jest aback our cowyard fence,
An’ if they don’t say there’s scenery they hain’t got a mite o’ sense;
Why yuh kin look fur miles around yuh an’ see nothin’ but th’ flat
Level prairie in th’ sunshine kivered in its grassy mat.
That is scenery—yuh kin look there jest as fur as yuh kin see
With no hills a-interposin’, er no rocks, er airy tree.
Oh, I’ve told my husband, Ephrum, that I’d gallavant no more
When ag’in I’d sot my foot on old Newbrasky’s fertile shore.

Then I’m worried so ’bout Rhody, fur she’s missin’ ever’ day
All her lessons on th’ melojun that paw bought fur her last May,
An’ she could perform amazin’; she could play “Old Hundred” nice
An’ another song beginnin’ “Happy Day that Fixed My Ch’ice.”
Yes, th’ singin’ teacher told me as we parted at th’ keers,
He was shore she’d play th’ organ in th’ church ’fore many years.
Now her notion’s highkerflutin’, a pianner she wants now,
An’ her paw sez he will get it soon as he kin sell a cow,
Sez he kin dispose o’ Muly—I jest told him no sir-e-e
Not fur no new-fangled nonsense—Muly’s my cow, an’ you see
He’s jest got a spite ag’in her ’cause she’s got a lengthy tail
An’ in fightin’ skeeters sometimes whicks it in th’ milkin’ pail.
Oh, I’ll be the gladdest mortal when I reach th’ kitchen door
Of that dear old farmhouse standin’ on Newbrasky’s fertile shore!

No, I don’t enjoy th’ city where the wimmen folks is dressed
Monday an’ clean through till Saturday all in their Sunday best.
I jest like to ketch my wrapper up ’n’ pin it ’round my waist,
Carin’ not a single copper if my shoe-string comes unlaced,
Then go out an’ milk old Muly an’ turn out th’ spotted calf
While th’ chickens giggle ’round me an’ the speckled roosters laff,
Then go in th’ summer kitchen, set me down an’ churn a spell,
Till time comes t’ put th’ victuals on an’ ring th’ dinner bell.
Yes, I love th’ peaceful quiet o’ th’ farm where it’s so still,
Nothin’ but th’ ducks a-quackin’ ’n’ pigs a-squealin’ fur their swill,
Nothin’ but th’ geese a-clackin’ ’n’ the bawlin’ o’ th’ cows,
An’ th’ nickerin’ o’ th’ hosses as they’re comin’ t’ th’ house;
Oh, I want t’ leave th’ city with its racket an’ its roar
An’ git back there t’ the silence o’ Newbrasky’s fertile shore!

—Copyright by Harr Wagner Co., San Francisco, and used by kind


permission of author and publisher.

“FUZZY-WUZZY”
By Rudyard Kipling

We’ve fought with many men acrost the seas,


An’ some of ’em was brave an’ some was not:
The paythan an’ the Zulu an’ Burmese;
But the Fuzzy was the finest o’ the lot.
We never got a ha’porth’s change of ’im:
’E squatted in the scrub an’ ’ocked our ’orses,
’E cut our sentries up at Suakim,
An’ ’e played the cat an’ banjo with our forces.
So ’ere’s to you, Fuzzy-Wuzzy, at your ’ome in the Sowdan;
You’re a poor benighted ’eathen but a first-class fightin’ man;
We give you your certifikit, and if you want it signed
We’ll come an’ have a romp with you whenever you’re inclined.
We took our chanst among the Kyber hills,
The Boers knocked us silly at a mile,
The Burman guv us Irriwaddy chills,
An’ a Zulu impi dished us up in style;
But all we ever got from such as they
Was pop to what the Fuzzy made us swaller;
We ’eld our bloomin’ own, the papers say,
But man for man the Fuzzy knocked us ’oller.
Then ’ere’s to you, Fuzzy-Wuzzy, an’ the missis and the kid;
Our orders was to break you, an’ of course we went and did.
We sloshed you with Martinis, an’ it wasn’t ’ardly fair;
But for all the odds agin you, Fuzzy-Wuz, you bruk the square.

’E ’asn’t got no papers of ’is own,


’E ’asn’t got no medals nor rewards
So we must certify the skill ’e’s shown
In usin’ of ’is long two-handled swords;
When ’e’s ’oppin’ in an’ out among the bush
With ’is coffin-’eaded shield an’ shovel-spear,
A ’appy day with Fuzzy on the rush
Will last a ’ealthy Tommy for a year.
So ’ere’s to you, Fuzzy-Wuzzy, an’ your friends which is no more,
If we ’adn’t lost some mess-mates we would help you to deplore;
But give an’ take’s the gospel, an’ we’ll call the bargain fair,
For if you ’ave lost more than us, you crumbled up the square!

’E rushes at the smoke when we let drive,


An’, before we know, ’e’s ’ackin’ at our ’ead;
’E’s all ’ot sand an’ ginger when alive,
An’ ’e’s generally shammin’ when ’e’s dead.
’E’s a daisy, ’e’s a duck, ’e’s a lamb!
’E’s a injia-rubber idiot on the spree,
’E’s the on’y thing that doesn’t care a damn
For the Regiment o’ British Infantree.
So ’ere’s to you, Fuzzy-Wuzzy, at your ’ome in the Sowdan;
You’re a pore benighted ’eathen but a first-class fightin’ man;
An’ ’ere’s to you, Fuzzy-Wuzzy, with your ’ayrick ’ead of ’air—
You big black boundin’ beggar—for you bruk a British square.

THOUGHTS FROM BUB


By Leonard G. Nattkemper

My name is Bub, ’cuz papa sed


He’d ruther call me so than Ned.
But mamma calls me ’ist her beau—
W’en I am good, I mean, you know.

So, I ’ist hardly knows my name


I guess—I bet ’ist all the same,
I’m papa’s boy an’ mamma’s dear,
An’ I be glad ’ist ’cuz I’m here.

It’s hard to make a name, I s’pose,


W’en they have used ’bout all o’ those
That they have heard or that they’ve read—
O’ course, there’s more w’en people’s dead.

An’ now I wonder if that I


Will leave my name w’en I must die.
I guess it’s so, ’cuz we ’ist call
Angel’s last name for them all.

I’m glad I’m not an angel yet,


Whose names are less than mine, I bet,
Still it must be nice to see
All the folks that used to be.

Oh, my, I don’t know what to say


About my names, ’cuz every day
My mamma finds a new one, too—
I’m ’fraid she’s left no names for you.

The bestest thing in all this worl’


Is, I’m a boy an’ not a girl,

You might also like