Professional Documents
Culture Documents
FOURTH EDITION
Tony Gaddis
Godfrey Muganda
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
Other names may be trademarks of their respective owners.
Title: Starting out with Java. From control structures through data structures /
Tony Gaddis, Haywood Community College, Godfrey Muganda, North
Central College.
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
21. Chapter 21 Binary Trees, AVL Trees, and Priority Queues 1287
1. Index 1353
1. 1.1 Introduction 1
1. Hardware 2
2. Software 5
1. What Is a Program? 6
2. A History of Java 8
1. Language Elements 8
3. Variables 11
2. Programming Challenge 25
2. 2.2 The print and println Methods, and the Java API 33
4. Identifiers 42
5. Class Names 44
1. Integer Division 57
2. Operator Precedence 57
1. Reading a Character 89
2. Mixing Calls to nextLine with Calls to Other Scanner
Methods 89
3. An Example Program 94
6. Flags 118
2. Precision 164
4. Flags 167
11. 4.11 Generating Random Numbers with the Random Class 249
1. Shadowing 379
11. 7.11 The Selection Sort and the Binary Search Algorithms 463
7. Capacity 479
A RAINY DAY
By Ellye Howell Glover
SCHOOL’S COMMENCED
By Leonard G. Nattkemper
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?
A THURRU’ REST
Anonymous
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.
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!
KISSING’S NO SIN
Anonymous
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
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.
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!
“FUZZY-WUZZY”
By Rudyard Kipling